in reply to how to parse large files
my @items = (); foreach my $subset ( keys %lookingFor ) { foreach my $item ( @$subset ) { push @items, $item; } } my $rxMatchItems; { local $" = q{|}; $rxMatchItems = qr{(?:@items)}; }
As others have pointed out, open the output file once at the beginning of the script then the remainder of the code could be reduced to something like
while ( <$fh> ) { next unless m{$rxMatchItems}; print $writeFh $_; }
This approach all depends on whether your items can easily be combined into one regex, but I think it might be more efficient if feasible.
I hope this is of use.
Cheers,
JohnGG
|
|---|