in reply to how to parse large files

If at all possible I would try to go through the combinations of items once at the beginning of the script, taking the process out of the while ( <$fh> ) { ... } loop, building a single regex to match any wanted line. Something like

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