in reply to Speed of opening and closing a file 1000s times

Just open all the files that need opening then iterate through the file e.g
use IO::File; my %fhs = map { my $fh = IO::File->new($_, 'w') or die "ack [$_]: $!"; $_ => $fh; } @natures; while(<FILE>) { for my $match (keys %fhs) { print {$fhs{$match}} $_ if /$match/; } } close $_ for values %fhs;
So that will only open the files once and iterate through the file once, which should do what you want.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Speed of opening and closing a file 1000s times
by seaver (Pilgrim) on Nov 03, 2003 at 16:59 UTC
    Perfect, thanks!

    S