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);
In reply to Very slow array searching by Rafaqat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |