Perl: the Markov chain saw | |
PerlMonks |
Re: Merge arrays - seeking slicker approachby roboticus (Chancellor) |
on Dec 21, 2010 at 15:12 UTC ( [id://878278]=note: print w/replies, xml ) | Need Help?? |
I don't know of a way to do so, but List::MoreUtils has a handy function uniq to handle the first case:
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.
In Section
Seekers of Perl Wisdom
|
|