use Benchmark qw( :DEFAULT  cmpthese );

$SIG{INT} = sub {  unlink 'data' ; exit} ;

my ($debug , $flex, $l, $n, $data, $fh, $ret, @ret) = 0 ;

{
	local $/  = undef;
	use Fatal qw( open );
	open $fh, 'snip.txt';
	$data = <$fh> ;
	close $fh;
	open $fh, '>data';
	print $fh $data   x 850  ;
	close $fh;
}

END { unlink 'data'  }

no warnings;
my @tokens = ( 
	qw[ EMAIL \b(?:\w+[.]?)+\w+\@(?:\w+[.])+[a-z]{2,3}\b ],
	qw( WORD  [a-z]+                                     ),
	qw( NUM   [0-9]+                                     ),
	qw( EOL   \n                                         ),
	qw( ERROR  .                                         ),
);

use warnings;

sub lex { 
        $l->nextis( \$n ) ; 
	return ('',undef) if $l->eoi;
	($n->name, $n->text);
};


sub Parse_Lex {
	use IO::File ;  use Parse::Lex ;

	Parse::Lex->skip('[ \t]*') ;
	$l = new Parse::Lex @tokens  or die;
	$l->from( new IO::File 'data' ) ;
  	1 while lex;
}

sub Parse_Flex {
        use Parse::Flex;
        yyin   'data' ;
	1 while yylex;
	#print "@ret"  while   @ret = yylex ;
}




cmpthese ( 1  , { old=>\&Parse_Lex, new=>\&Parse_Flex} ) ;


__DATA__
