use strict; use IO::File; my $f = new IO::File "filetoread.something", "r" or die "Can not open input file"; while (<$f>) { # do stuff ... } undef $f; # close the file # note that you don't even have to do this # this is optional because the file will be # closed when Perl script finishes. I am just # forcing an early file closure here.