my @fhandle_array; for $filename (@filenames) { local *FILE; #so that FILE is limited in scope open(FILE, "$filename") or die "could not open file\n"; #push the filehandle into your filehandle array push(@fhandle_array, *FILE); } #### sub close_files() #args: none. uses global array: fhandle_array { my $handle; foreach $handle (@fhandle_array) { close $handle; } }