in reply to Better way to write these checks?
?? List::AllUtils::http://search.cpan.org/perldoc/List::AllUtils#any_BLOCK_LIST#any?
use List::AllUtils qw/ any /; sub is_in_num { my( $num, $list ) = @_; return any { $num == $_ } @$list; } sub is_in_str { my( $str, $list ) = @_; return any { $str eq $_ } @$list; }
Smart matching?? http://perldoc.perl.org/perlop.html#Smartmatch-Operator
use 5.010; *is_in_num = *is_in_str = sub { my( $str, $list ) = @_; return $str ~~ $list; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Better way to write these checks?
by Ransom (Beadle) on Jun 29, 2012 at 12:45 UTC |