Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Since Perl 5.6, you can create a filehandle in a scalar variable so you don’t have to use a bareword. This makes many things, such as passing a filehandle as a subroutine argument, storing them in arrays or hashes, or controlling its scope, much easier. Although, you still need to know how to use the barewords because you’ll still find them in Perl code and they are actually quite handy in short scripts where you don’t benefit that much from the filehandles in a variable.
If you use a scalar variable without a value in place of the
bareword in open, your filehandle
ends up in the variable. People typically do this with a lexical
variable since that ensures you get a variable without a value; some
like to put a _fh on the end of these
variable names to remind themselves that they are using it for a filehandle: