in reply to Matching Regular expression at EOF
Or maybe the file is huge, but the pattern is simple. Then there's still a simple solution:my $last = (map {/^.*(pat)/} <>)[-1];
Ormy ($last) = (`grep pat file`)[1] =~ /^.*(pat)/;
use autodie; open my $fh, "<", "file"; my $last; while (<>) { $last = $1 if /^.*(pat)/; }
|
|---|