in reply to Questions about Grep
If you want to grep a file in Perl, you can read it into an array first:
There's also the File::Grep module from CPAN which provides some easy-to-use file grepping functionality.use strict; open my $fh, "file.txt" or die "Error opening file.txt: $!"; my @lines = <$fh>; my @matches = grep /pattern/, @lines;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Questions about Grep
by pc88mxer (Vicar) on May 29, 2008 at 19:14 UTC | |
Re^2: Questions about Grep
by Anonymous Monk on May 29, 2008 at 19:23 UTC |
In Section
Seekers of Perl Wisdom