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
In reply to Help with a faster loop by gzayzay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |