Perl's lack of 'in' keyword

Simon Wilcox essuu at ourshack.com
Tue Oct 7 16:27:41 BST 2008


Paul Makepeace wrote:
> ... is starting to frustrate me. It's the one feature I am finding I'm
> really missing from That Other Language.
> 
>   if ($bar in @foo) {
>     # ...
>   }

Perhaps:

use List::Util qw( first );

if (first{ $_ eq $bar } @foo) {
   # ...
}

S.




More information about the london.pm mailing list