Rafaqat has asked for the wisdom of the Perl Monks concerning the following question:
1. sub checkNumber($) 2. { 3. my ($l_number) = @_; 4. my $l_status;<br> 5. my @matches= grep { /$l_number/ } @numbers; 6. if (@matches) { 7. $l_status="TRUE"; 8. } 9. else { 10. $l_status="FALSE"; 11. } 12. return $l_status; 13. }
The array has at least 20K elements. This piece of code is taking up almost 100% of the CUP cycles (Dual Xeon). Would somebody please suggest some alternative solution.1. $check=checkNumber($num1);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Very slow array searching
by dws (Chancellor) on Jul 29, 2003 at 07:16 UTC | |
|
Re: Very slow array searching
by PodMaster (Abbot) on Jul 29, 2003 at 06:49 UTC | |
|
Re: Very slow array searching
by pzbagel (Chaplain) on Jul 29, 2003 at 07:11 UTC | |
|
Re: Very slow array searching
by BrowserUk (Patriarch) on Jul 29, 2003 at 08:06 UTC | |
|
Re: Very slow array searching
by dragonchild (Archbishop) on Jul 29, 2003 at 12:35 UTC |