Lexical filehandles can be passed easily as arguments, filehandles cannot. Typeglobs can (or at least references to them can), but that's kinda messy. Consider sticking with lexical variables, and make sure to declare them first, so you know that they're really lexical and not local or global. I.e.
my $fh;
open $fh, $filename;
Also consider using IO::Handle
or IO::File
as options. Used to be FileHandle
but was informed by ysth below that FileHandle
now just uses 'IO::Handle' in turn, which is news to me since 5.6, but there's a lot to learn here. :-)
Also, don't forget use strict
:-)