Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- PERL 4.0 Reference Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

     eof(FILEHANDLE)

     eof()

     eof     Returns 1 if the next read on FILEHANDLE will return
             end of file, or if FILEHANDLE is not open.  FILEHAN-
             DLE may be an expression whose value gives the  real
             filehandle  name.  (Note that this function actually
             reads a character and then ungetc's it, so it is not
             very  useful  in  an  interactive  context.)  An eof
             without an argument returns the eof status  for  the
             last file read.  Empty parentheses () may be used to
             indicate the pseudo file formed of the files  listed
             on the command line, i.e. eof() is reasonable to use
             inside a while (<>) loop to detect the end  of  only
             the  last  file.   Use  eof(ARGV) or eof without the
             parentheses to test EACH file in a while (<>)  loop.
             Examples:

                  # insert dashes just before last line of last file
                  while (<>) {
                       if (eof()) {
                            print "--------------\n";
                       }
                       print;
                  }

                  # reset line numbering on each input file
                  while (<>) {
                       print "$.\t$_";
                       if (eof) {     # Not eof().
                            close(ARGV);
                       }
                  }

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson