> 'plain_regex' => sub { if ( $string =~ /^.{38}\|[BNPG]\|/ ) { > my $a = $_ } }, > 'plain_regex' => sub { if ( $string =~ /^.{38}\|N\|/ ) { my $a = $_ } > }, > > What was interesting to me was that although, predictably, the > substring/regex combo was consistently the best performer for the > original match, regexing the whole line was consistently the best > performer when looking for "|N|". This seems to fly in the face of > the conventional wisdom that substr is faster than m// when you know > what you're looking for and where you're looking for it.
I believe the conventional (faster?) way to do a regex search when you want to start matching a fixed number of characters in is along the lines of: pos($string) = 38; print "found!\n" if $string =~ /\G\|[BNPG]\|/; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>