in reply to Example for EOF
Normally you don't use eof but rather check the return value of whatever you're using to read the filehandle. Usually that's the diamond operator (<>, aka readline):
open my $filehandle, "<", $filename or die "Oof! $!"; while (<$filehandle>) { do_something(); } close $filehandle; do_something_else()
When the conditional of the while becomes false, then there are no more lines to read and you've reached the end of the file and in your case do_something_else looks like it should display a message.
|
|---|