gzayzay has asked for the wisdom of the Perl Monks concerning the following question:
I am writing a search engine to sort through a lot of data. I have developed a loop that is working fine but it is very slow. Thus, I will like any suggestion on a faster loop. Below it my code and I will like to make faster and smart.
sub process_files { if (opendir(TEST, $dir_path)) { @files = sort grep{$_ ne '.' and $_ ne '..'} readdir(TEST); #print "\n@files[0]\n"; for ($j = 0; $j <= $#files; $j++) { $file_path = $dir_path."\\".@files[$j]; read_files(); } } else { die ("Could not Opendir $!\n"); }closedir TEST; } sub read_files { if ($file_path =~ /defines|sccpch|sms81154|sms97767/) { next; } elsif(!($file_path =~ /defines|sccpch|sms81154|sms97767/)) { if (open(FILES, $file_path)) { if (!($file_path =~ /\.lfa|\.zip|\.txt|UASTG/)) { print (DATA "$file_path\n"); } } else { die ("Could not open[$file_path], $!\n"); } }close FILES; }
Thanks,
Edman
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with a faster loop
by JediWizard (Deacon) on Mar 01, 2006 at 14:44 UTC | |
by CountOrlok (Friar) on Mar 01, 2006 at 16:00 UTC | |
by Anonymous Monk on Mar 01, 2006 at 19:38 UTC | |
by gzayzay (Sexton) on Mar 01, 2006 at 15:06 UTC | |
|
Re: Help with a faster loop
by graff (Chancellor) on Mar 02, 2006 at 05:15 UTC | |
by gzayzay (Sexton) on Mar 02, 2006 at 15:29 UTC |