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; }