AcornSearch - Acorn and RISC OS information searching
RISC OS Search
containing
"Nutty quip goes here!"
Home  |  About  |  Filebase Archive  |  StrongHelp Manuals  |  Newsgroups  |  Module Database
eof FILEHANDLE
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 name.  (Note that this function actually
reads a character and then ungetc()s it, so it is not very useful in an
interactive context.)  Do not read from a terminal file (or call
eof(FILEHANDLE) on it) after end™of™file is reached.  Filetypes such
as terminals may lose the end™of™file condition if you do.

An eof without an argument uses the last file read as argument.
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:

while (<>) {
print "$.\t$_";
close(ARGV) if (eof);   # Not eof().
}

while (<>) {
if (eof()) {
print "™™™™™™™™™™™™™™\n";
close(ARGV);        # close or break; is needed if we
}
print;
}

Practical hint: you almost never need to use eof in Perl, because the
input operators return undef when they run out of data.


[sh-index] Back to list of manuals