# insert dashes just before last line of last file while (<>) { # Do stuff with each line if (eof) { # check for end of current file print "I am at the end of the file\n"; close(ARGV); # close or last; is needed if we # are reading from the terminal } }