in reply to Opening multiple filehandlers
Now all of your filehandles are in @FH, and you can loop through there and do what you will with them. Will this work for you?use Symbol; my $N = 15; my @FH; for my $i (0..$N-1) { my $fh = gensym; open $fh, ">$i.txt" or die "Can't open $i.txt: $!"; push @FH, $fh; }
Note that in Perl 5.6.0 you can just do:
And it Just Works. You could then take out the 'use Symbol' and 'gensym' bits.open my $fh, ">$i.txt" or die "Can't open $i.txt: $!";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Opening multiple filehandlers
by leons (Pilgrim) on Apr 06, 2001 at 12:05 UTC |