=over =item eof FILEHANDLE =item eof () =item eof Returns 1 if the next read on FILEHANDLE will return end of file, or if FILEHANDLE is not open. FILEHANDLE may be an expression whose value gives the real filehandle. (Note that this function actually reads a character and then Cs it, so isn't very useful in an interactive context.) Do not read from a terminal file (or call C on it) after end-of-file is reached. File types such as terminals may lose the end-of-file condition if you do. An C without an argument uses the last file read. Using C with empty parentheses is very different. It refers to the pseudo file formed from the files listed on the command line and accessed via the C<< <> >> operator. Since C<< <> >> isn't explicitly opened, as a normal filehandle is, an C before C<< <> >> has been used will cause C<@ARGV> to be examined to determine if input is available. In a C<< while (<>) >> loop, C or C can be used to detect the end of each file, C will only detect the end of the last file. Examples: # reset line numbering on each input file while (<>) { next if /^\s*#/; # skip comments print "$.\t$_"; } continue { close ARGV if eof; # Not eof()! } # insert dashes just before last line of last file while (<>) { if (eof()) { # check for end of current file print "--------------\n"; close(ARGV); # close or last; is needed if we # are reading from the terminal } print; } Practical hint: you almost never need to use C in Perl, because the input operators typically return C when they run out of data, or if there was an error. =back