while (<>) { print "$.\n"; } continue { close ARGV if eof; # Not eof()! }