Greg has quoted the appropriate documentation, so here's a quick rundown of what happens
$a = shift; # "-axt" is removed from @ARGV and assigned to $a
$b = shift; # "file1" likewise
push(@ARGV,$b); # "file1" inserted at end of @ARGV
$c = <>; # "file2" is removed from @ARGV, and its file
# handle opened, the first line of file2 is read
When the file handle for "file2" is opened, it sets the file name in $ARGV
. As Greg mentioned, @ARGV
and $ARGV
are completely different variables.
The internal workings of the diamond operator <>
is probably what is confusing you here, in that it does an approximate $ARGV = shift @ARGV