First of all, use qr// to precompile your patterns:
my @compiled_patterns = map { qx/$_/ } @matcharray;
Also don't slurp the file into an array. Use something more memory-efficient:
OUTER: while (my $line = <$file>) { INNER: for my $pattern (@compiled_patterns) { print $line, last INNER if $line =~ $pattern; } }
Cheers, Flo
In reply to Re: Usage of grep on a file
by rafl
in thread Usage of grep on a file
by tsk1979
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |