swissknife has asked for the wisdom of the Perl Monks concerning the following question:
Hello Dear Monks
in my script i am using a grep against each element in the array. this array containts around 8000 elements now and processing of each element is taking much time. this causes an script timeout on my remote system from where i execute this script. i am wondering if there is a way to improve the performance time? Below are the snippet of the code in question
my $path = "/tmp/testpatch"; opendir DIR, $path or die $!; my @tempfiles = readdir DIR; #this array has list of all the files, p +reviously processed and newly added (8000 files) closedir DIR; foreach my $strfile (@tempfiles) { if (!grep /$strfile/, @arraytocompare) #This array has list of files w +hich were processed in the passed { push (@newarray, $strfile); # in this array i get all the new files wh +ich i need to process now. } }
is there a fast grep? or i will have to live with it?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: improve performance
by Corion (Patriarch) on Jun 08, 2015 at 09:45 UTC | |
by swissknife (Sexton) on Jun 08, 2015 at 10:03 UTC | |
by marto (Cardinal) on Jun 08, 2015 at 10:25 UTC | |
by swissknife (Sexton) on Jun 08, 2015 at 10:41 UTC | |
by Corion (Patriarch) on Jun 08, 2015 at 10:43 UTC | |
by swissknife (Sexton) on Jun 08, 2015 at 12:18 UTC | |
by Corion (Patriarch) on Jun 08, 2015 at 12:21 UTC | |
by Anonymous Monk on Jun 08, 2015 at 12:41 UTC | |
|
Re: improve performance
by pme (Monsignor) on Jun 08, 2015 at 09:53 UTC | |
|
Re: improve performance
by GotToBTru (Prior) on Jun 08, 2015 at 16:34 UTC | |
|
Re: improve performance
by Anonymous Monk on Jun 08, 2015 at 09:46 UTC | |
|
Re: improve performance
by marioroy (Prior) on Jun 12, 2015 at 13:23 UTC |