in reply to File handles - there must be a better way

Sounds like you're stuck on old-style global file handles (open FOO, ...). This forces you to maintain an array of file handle names to avoid collisions, since you can only have one file handle of a given name. If you're already using lexical file handles, disregard the rest of this post!

Use lexical file handles instead (in general, this is preferred; there is zero advantage to using the other style, and even if the only thing you get from lexical file handles is lexical scope, that's a net win):

my %filehandle_of; foreach my $filename (@filenames) { # here $filehandle is a reference to a new anonymous filehandle in + each iteration, you can push it into an array if you don't need the +mapping instead if (open my $filehandle, '<', $filename) { $filehandle_of{$filename} = $filehandle; } else { warn "could not open '$filename' for reading: $!\n"; next; } }

See also perldoc -f open.