#!/usr/bin/perl use warnings; use strict; my $ssprdir = "/apps/inst1/metrica/TechnologyPacks/ON-SITE/summaryspr/"; opendir(my $sspr, $ssprdir) or die "Can't read $ssprdir - $!\n"; my @files = grep { ! -d $_ } map { "$ssprdir/$_" } readdir $sspr; closedir $sspr; for my $file (@files) { unless (open(my $fh, "<", $file)) { warn "Unable to open $file - $!\n"; next; } # ... while (<$fh>) { next unless /$old_schema/i; # ... print "$old_schema|$new_schema_str|$found_status|$migratestr|$rename_str|$file\n"; } close $fh; } __END__