I use the following (from perlfaq4):
my %seen; my @mergedkeys = grep !$seen{$_}++, @array1, @array2;
It's a bit of a doozie to understand, but it's just one of those patterns you keep seeing and you memorise.
Bonus: it preserves order.
In reply to Re: Merge arrays - seeking slicker approach
by ikegami
in thread Merge arrays - seeking slicker approach
by puterboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |