use strict; use warnings; open IN, "file.txt" or die "can't open : $!\n"; while () { # perform some tests on $_ # if its a good line, print it. } close (IN);