in reply to @array1 vs @array2
Use a hash to count the number of occurances of each id in @array2, like this:
my %count; foreach (@array2) { my ($id) = split /,/; $count{$id}++; } foreach (sort @array2) { my ($id) = split /,/; print "$id: $count{$id}\n"; }
If some of the ids in @array1 don't appear in @array2 then you'll need to account for that in the second loop.
But, all in all, I think you should probably rethink your data structure.
--
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
|
|---|