open FH, "foo" or die "Can't open foo: $!"; while () { ## current line is in $_, process it } close FH or warn "Error closing foo: $!"; #### while (<>) { ## line is in $_ } #### $ process.pl foo.txt bar.txt baz.txt