foreach my $file (readdir(DIR)){ if($file ne '.' and $file ne '..' and ! (-d $file)){ print "$file\n"; #below is line 13 ithe original program open FILE, $dir.$file or die "$! $file"; foreach my $line (){ if ($line =~ /use SBSDBRUN/){ $found = $file; last; } } if (! $found ){ push @files, $file; } undef ($found); close FILE; } }