#To process every line of those files one at a time, use: { local @ARGV = <*.txt>; while( <> ) { # $_ contains the lines of the files one at a time; for each file in turn # To display file(line no): line for every .txt file in the current directory use: chomp; print $ARGV, '(', $., '):', $_; } }