#!/usr/bin/perl my @filehandles; #make array of 10 file handles for($i=0; $i<10; $i++) { #localize the file glob, so FILE is unique to # the inner loop. local *FILE; open(FILE, ">file$i.txt") || die; #push the typeglobe to the end of the array push(@filehandles, *FILE); } $count=0; #loop through the file handles. # treat $file as a normal file handle foreach $file (@filehandles) { print $file "File $count"; close $file; $count++; }