my $prev; while (<>) { if (not defined $prev or $prev ne $ARGV) { print "now reading from $ARGV\n"; } print; $prev = $ARGV; }