in reply to while loop logic
use 5.006000; # Perl 5.6.0+ use strict; use warnings; use Regexp::List (); my $txt; { # Remove comments. open(my $txtfh, '<', $txtf) or die("Can't open $txtf : $!\n"); # Read entire file into memory. local $/; $txt = <$txtfh>; $txt =~ s{/\*.*?\*/}{}sg; # Remove comments. $txt =~ s{/\*.*/}{}s; # Remve unmatched comment. } my @matches = ...; my $regexp = Regexp::List ->new(modifiers => 'i', quotemeta => 0) ->list2re(@matches); open(my $txtfh, '<', \$txt); while (my $line = <$txtfh>) { my @fld = split(/\|/, $line); print "$fld[0] $fld[2] sequence=$fld[4] $fld[5]" if $line =~ $regexp; }
Update: Oops! holli already posted the same thing.
|
|---|