open($fh, $fname) || die $!; while (my $line = <$fh>) { # Do something with each $line... } close $fh;