in reply to improve performance
Whenever you want a fast lookup, try to use a hash. This will only work if your elements exist as single lines instead of actual substring matches. Also note that if $strfile contains regex meta characters (like *, . or +, or []) your code will not work as you might think.
Using a hash would result in:
my %lookup = map { $_ => 1 } @arraytocompare; foreach my $strfile (@tempfiles) { if( $lookup{ $strfile } ) { push (@newarray, $strfile); }; };
But I really, really doubt that searching through 8000 array entries will slow your program down that much. Are you certain that this is where your performance bottleneck is?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: improve performance
by swissknife (Sexton) on Jun 08, 2015 at 10:03 UTC | |
by marto (Cardinal) on Jun 08, 2015 at 10:25 UTC | |
|
Re^2: improve performance
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 |