in reply to Working out which file a script is working on

As japhy mentions, the $ARGV holds the current filename when reading from either <> or <ARGV>. However, note that the line number in $. (and the one reported from the die function) won't be reset between files unless you explicitly check for the end of files and close the filehandle (using the eof function without parens --- see perlfunc:eof). The basic framework is:

#!/usr/bin/perl -w use strict; while(<>){ chomp; my $verified = 0; # do verification stuff die "problem in file $ARGV at line $." unless $verified; } continue { close ARGV if eof; }

Note, you can put the eof test at the bottom of the loop rather than in the continue block, but if it is in the continue block it'll still be checked even if you use next inside your loop.