in reply to Merge arrays - seeking slicker approach

puterboy:

I don't know of a way to do so, but List::MoreUtils has a handy function uniq to handle the first case:

#!/usr/bin/perl use strict; use warnings; use List::MoreUtils qw(uniq); my @a = qw(alpha beta gamma); my @b = qw(delta kappa gamma); my @c = uniq(@a, @b); print join(", ", @c), "\n";

You'll also find some interesting items in List::Util, Hash::Util and Scalar::Util.

But if you find the temporary a distraction and don't want to include a module for just that purpose, just hide it in a subroutine and go ahead and use the temporary in your subroutine. After all, a temporary isn't necessarily inefficient. So by writing a subroutine with a good name, you can make the code cleaner and self-documenting at the same time, as in the above example. I find that some code can be difficult to read when there's "too much action" happening in a statement, and you may find it difficult to maintain if the statement is too hard to create. So just relax, write a subroutine to do your dirty work, and use it--or include an appropriate module, where someone has already done the dirty work for you!

...roboticus

When your only tool is a hammer, all problems look like your thumb.