in reply to Improving the efficiency of code when processed against large amount of data
To add to what the other monks have said ...
There's an error and at least one weirdness in your code:
#!/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__
Also, if $old_schema is really supposed to be a string and not a regular expression, you might consider using index instead of engaging the RE engine.
|
|---|