in reply to Matching arrays with different number of elements and element size
What can be the differences between the two arrays? Are there only additional elements in the second, or can there be missing ones as well? Are all elements of the first array substrings of the second as is the case in your example?
If the strings in array1 are substrings of array2, you can use index which lets you find if a string is found in another (easier to use than pattern matching), and the built-in grep can let you select elements from a list (untested):
my @output; for my $name (@array1) { print "$name :" join ", ", grep { index $_, $name >= 0 } @array2 ; print "\n"; }
|
|---|