I'd recommend to follow what toolic advised: close the file instead of manually nulifying $. The value of $. is reset automatically when the file is closed, so the following does what you need:
while (<>) {
print "$ARGV.$.:$_\n";
close ARGV if eof;
}