I got two arrays
@masterarray =(titles1|index1|username1|comment1, titles2|index2|username2|comment2, ....);
@keyarray = (index1,$index2,$index3,..);
I got to extract all elements in @masterarray which consists identicle element in @keyarray So, I have worked out as;
foreach $line(@masterarray){
($a,$b,$c,$d) = split(/\|/, $line);
foreach $key(@keyarray){if ($key eq $b) {push (@wantedarray, $line) ; last;}
}}
I am sure this is not a good way to do it if two arrays are getting bigger there must be some efficient way to do it..
Thanks for any kind help..
@masterarray =(titles1|index1|username1|comment1, titles2|index2|username2|comment2, ....);
@keyarray = (index1,$index2,$index3,..);
I got to extract all elements in @masterarray which consists identicle element in @keyarray So, I have worked out as;
Code:
foreach $line(@masterarray){
($a,$b,$c,$d) = split(/\|/, $line);
foreach $key(@keyarray){if ($key eq $b) {push (@wantedarray, $line) ; last;}
}}
I am sure this is not a good way to do it if two arrays are getting bigger there must be some efficient way to do it..
Thanks for any kind help..