in reply to Re^2: anonymous filehandes?
in thread anonymous filehandes?

Perl Cookbook just refers to it as "<>" and doesn't mention any name for it.

Regarding your other response, yes, perl is smart enough to automagically close any open files when the program exits, regardless of how/when they were opened. It may close files opened by <> sooner (e.g., when each of them hits EOF), but I haven't found anything which clearly states that one way or the other.

Replies are listed 'Best First'.
Re^4: anonymous filehandes?
by Fletch (Bishop) on Jul 09, 2007 at 17:18 UTC

    If you read perlop's description of <> (the "null filehandle" in its nomenclature) it expands out the construct to:

    unshift(@ARGV, '-') unless @ARGV; while ($ARGV = shift) { open(ARGV, $ARGV); while (<ARGV>) { ... # code for each line } }

    When you re-open any existing filehandle the underlying file is implicitly closed; so each time through the loop the prior file will be closed before the handle is reused.