in reply to mix arrays

You can do this:

use Data::Dumper; my @a_array = ('apple 2', 'orange 5', 'pear 3',); my @b_array = ('apple', 'apple', 'apple', 'orange', 'orange', 'pear', +); my @c_array; for my $item_1 (@b_array){ for my $item_2 (@a_array){ push @c_array, $item_2 if $item_2=~/^$item_1/; } } print Dumper \@c_array;
Produces ...
$VAR1 = [ 'apple 2', 'apple 2', 'apple 2', 'orange 5', 'orange 5', 'pear 3' ];

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me