Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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 about the Monastery: (6)
As of 2015-07-02 04:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (27 votes), past polls