DEV Community

Johan Lindstrom
Johan Lindstrom

Posted on

use List::AllUtils;

Did you know about the module List::AllUtils?

It puts the goodness of List::Utils and List::MoreUtils into one nice package. Or... was it List::Util and List::MoreUtils? List::MoreUtil? Or is it actually List::SomeUtil? Gaaahrhg!

Well, that's the problem it solves. Now you can forget about which of those modules were named what, use List::AllUtils; and just go on with your life. It also adds a few more nice functions from List::UtilsBy.

Props to Dave Rolsky (@houseabsolute on the Twitter machine) for being lazy on our behalf!

RTFM

It's a good idea to be roughly aware what kinds of operations are available for dealing with lists for next time you need them.

Read the manual on meta::cpan, or locally using perldoc (after installing the module, probably using the cpanm client).

perldoc List::AllUtils

Highlights

Here are a few standard things on the level of basic language features you should know about.

  • sum, sum0
  • min, max
  • uniq

And a few niceties worth taking a look at.

  • any, all
  • pairmap, pairgrep
  • pairwise
  • part
  • sort_by, nsort_by

But there are many more useful functions in there.

Used correctly these could save you a lot of time and bugs by replacing imperative for loops with more expressive and precise flow control.

Which function helped you out the most? Add to the discussion below, or on /r/perl!

Top comments (0)