2010/1/19 Parag Kalra <paragka...@gmail.com>: > Hello All, > > I have 2 arrays. I have written a script that searches each and every value > of first array in the second array. Each & every value of Source Array > should occur only once in the target array but it can occur anywhere. > > If any of the source value doesn't occur or occur multiple times then the > script reports to the user. > > This script is working fine for small arrays. > > But I tried executing the script for 2 arrays each of which containing > around 7,00,0000 elements and it is taking very long time. > I am using nested 'for' loops to make this search. How can I optimize it > further to search source array in target array.
Have a look at List::Util, it's a part of the standard distribution. I think 'first' will do what you want. There is also List::MoreUtils available at CPAN. Randal has created some nice articles[1] that will help you along. Good luck, Dp. [1] http://www.stonehenge.com/merlyn/LinuxMag/col97.html -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/