@ARGV = @filenames; while (<>) { $filename = shift @filenames if $. == 1; ... }