How do pass one array and one string as arguments to a function?

前端 未结 5 1408
感情败类
感情败类 2021-01-13 14:44

Because I can\'t find a convenient way to check if $str is in @array, I\'m trying to make one myself, but it is not working.

I guess it is

5条回答
  •  醉话见心
    2021-01-13 15:27

    You may want to check any in the List::MoreUtils package, you just use it like:

    use List::MoreUtils 'any';
    
    my @f= qw(1 2 3 4);
    my $k=10;
    
    print "yes\n" if( any { $_ == $k } @f );
    

    check the documentation in:

    perldoc List::MoreUtils.
    

提交回复
热议问题