in reply to mix arrays
Another small variation:
>perl -wMstrict -le "my @a = ('apple 2', 'orange 5', 'pear 3'); my @b = qw(apple apple apple orange orange pear); ;; my %fruits; ++$fruits{$_} for @b; ;; my @c; push @c, ($_) x $fruits{ (split)[0] } for @a; printf qq{'$_' } for @c; " 'apple 2' 'apple 2' 'apple 2' 'orange 5' 'orange 5' 'pear 3'
|
|---|