Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: mix arraysby rjt (Curate) |
on Aug 07, 2013 at 16:57 UTC ( [id://1048382]=note: print w/replies, xml ) | Need Help?? |
I would initially put a mapping from @b to @a into a translation mapping hash: my %b_a_map = map { (split / /)[0] => $_ } @a;And then generating @c becomes a simple O(n) loop: my @c = map { $b_a_map{$_} } @b;@c will now look something like:
Edit: Output re-run with verbatim OP input, instead of my slightly modified test input.
use strict; use warnings; omitted for brevity.
In Section
Seekers of Perl Wisdom
|
|