in reply to line by line match on an array of strings
Instead of reading line by line, you can slurp in the contents of the entire file into a scalar variable and then look for a match against an array of strings.
local $/ = undef; open(FH,"<","test.txt") or die "Could not open the file due to $!"; my $fcontent = <FH>; close FH; foreach (@typedefs) { if ($fcontent =~ /$_/){ # perform various actions here if line match } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: line by line match on an array of strings
by halley (Prior) on Jan 09, 2008 at 14:20 UTC |
In Section
Seekers of Perl Wisdom