Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Better way to write these checks?

by moritz (Cardinal)
on Jun 29, 2012 at 12:38 UTC ( #979115=note: print w/ replies, xml ) Need Help??


in reply to Better way to write these checks?

use List::MoreUtils qw/any/; sub is_in_num { my $matcher = shift; any { $matcher == $_} @{$_[0]} } sub is_in_str { my $matcher = shift; any { $matcher eq $_} @{$_[0]} }

For more general advice on how to refactor code like that, read Higher-Order Perl.


Comment on Re: Better way to write these checks?
Download Code
Re^2: Better way to write these checks?
by Ransom (Beadle) on Jun 29, 2012 at 12:44 UTC
    Thanks for the link. I think that's what I needed to find for several issues in my code.
Re^2: Better way to write these checks?
by Anonymous Monk on Jun 29, 2012 at 12:50 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://979115]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-10-31 04:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (214 votes), past polls