my @textfiles = (); @textfiles = glob("*.txt"); foreach my $textfile (@textfiles){ open ( my $inf_fh, '<', $textfile ) or die "Can't open $textfile $!\n"; while (<$inf_fh>) { unless (1.../^Something/) { print $_; } } close($inf_fh); }