Perl: if ( element in list )

后端 未结 10 635
栀梦
栀梦 2021-01-30 06:05

I\'m looking for presence of an element in a list.

In Python there is an in keyword and I would do something like:

if element in list:
            


        
10条回答
  •  悲&欢浪女
    2021-01-30 06:42

    Probably Perl6::Junction is the clearest way to do. No XS dependencies, no mess and no new perl version required.

    use Perl6::Junction qw/ any /;
    
    if (any(@grant) eq 'su') {
        ...
    }
    

提交回复
热议问题