[Israel.pm] Is there an operator like IN in perl

Yitzchak Scott-Thoennes sthoenna at efn.org
Thu Mar 5 09:43:33 PST 2009


On Wed, March 4, 2009 6:09 am, Shlomi Fish wrote:
> On Wednesday 04 March 2009 15:27:04 Amir E. Aharoni wrote:
>> use List::Util 'first';
>>
>> my @beatles = qw(John Paul George Ringo);
>>
>> if (first { $_ eq 'George' } @beatles) { print "George is in Beatles\n";
>>  }
>> if (first { $_ eq 'Amir' } @beatles) { print "Amir is in Beatles?!\n"; #
>> This is not printed
>> }
>
> This will be problematic if you're looking for an element that's false in
>  Perl.

> {{{{{{{{
> if (first { $_ == 0 } (100,0,30)) }}}}}}}}
>
> For these cases, any from List::MoreUtils would be preferable.

Or if ( defined first ... )





More information about the Perl mailing list