while (<>) { if (not defined $prev or $prev ne $ARGV) { print "reading $ARGV\n"; } print; print "and that's the end of $ARGV\n" if (eof); $prev = $ARGV; }