my $file = "/path-to/somefile"; open(FIL, $file) || die "Couldn't open $file - $!\n"; while () { #do stuff with each line of $file } close(FIL);