in a Perl program is the name for an I/O connection between your Perl process and the outside world. We've already seen and used filehandles implicitly:
is a filehandle, naming the connection between the Perl process and the standard input. Likewise, Perl provides
(for standard output) and
(for standard error output). These names are the same as those used by the C and C++ standard I/O library package, which Perl uses for most of its I/O.
Filehandle names are like the names for labeled blocks, but they come from yet another namespace (so you can have a scalar
, an array
, a hash
, a subroutine
, a label
, and now a filehandle
). Like block labels, filehandles are used without a special prefix character, and thus might be confused with present or future reserved words. Once again, the recommendation is that you use
letters in your filehandle; not only will the uppercase stand out better, but it will also guarantee that your program won't fail when a future reserved word is introduced.