For this if I scan line-by-line in a perl program then it will just slightly better than a C program.
You´re wrong. To scan the whole file you will have to slurp it into memory first. That´s bad, especially when the target for myExp is likely to be near the beginning of the file.
However, here is how to read a file at once and apply a regex to the content:
use strict;
my $data;
slurpfile ("yourfile.txt", $data);
print $1 if $data =~ /(expression)/m;
sub slurpfile
{
local $/ = undef;
open IN, "<", $_[0] or return 0;
$_[1] = <IN>;
close IN;
return 1;
}
| [reply] [d/l] |