PBP: 050 List Membership

The PBP suggests using the right, fast, tools to search for strings in lists.  Who wouldn’t?

It suggests using a table lookup to test for membership of strings – that’s a map to a hash, then a hash key search.

If it isn’t a string, it suggests using any() from List::MoreUtils.

I am generally in favor of these things, except that there’s a bunch of stuff in List::Utils and List::MoreUtils that I can never remember.  Those are a set of modules I know about but forget.  I should really get them to stick in my head.

I do have one environment where I can’t use modules, which is a terrible way to have to write Perl.  We’ve re-implemented the world on our own because we can’t be required to have our users run cpanm, and because old ActiveState made module install hard.  Ugh.  Which takes List::MoreUtils off the table.

Do these when you can.  Don’t be an idiot like me and forget they’re there.

Leave a Reply