open (DATA, "<.txt") or die "Can't open file $!\n"; while ($rec = ) { # Loop stuff here } close(DATA)