http://qs1969.pair.com?node_id=657943


in reply to How to juggle between two arrays that are not same size

the solution presented by kyle is somehow idiomatic, this would be a good choice. You can use an alternative form w/regular expressions in order to solve a more complicated pattern problem.

The regex-form of kyle's solution would be like:

... my @Names = qw'A B C'; my @FullRecord = qw'A_1 D_4 C_3 F_6 B_2'; # prepare temporary dictionary my %h; @h{@Names} = (); my @DesiredRecord = grep exists $h{ [/^([^_]+)/]->[0] }, @FullRecord; print "@DesiredRecord\n"; ...

Regards

mwa