in reply to Re: Minimisation of codes (if grep {})
in thread Minimisation of codes (if grep {})

Thanks for that. But by using  /^\Q$intermediate_array[11]\E$/ I can grep exact word. Is this List::Util::any checks for exact words or works like simple grep????

Replies are listed 'Best First'.
Re^3: Minimisation of codes (if grep {})
by hippo (Archbishop) on Oct 01, 2015 at 11:10 UTC
    Is this List::Util::any checks for exact words or works like simple grep????

    One of the many, many great things about Perl is the volume and quality of the documentation. It will stand you in excellent stead to become familiar with how to access it. If you have already read the relevant documentation but have not understood it then by all means describe which part is giving you the trouble so that the documentation might be made even clearer.

      #!/usr/bin/perl use Modern::Perl; use List::Util qw(first max maxstr min minstr reduce shuffle sum); my @pantry = ("Panc", "Pancake", "Panmix"); my $total = 0; $total++ if( any { Panc } @pantry); #$total++ if grep { /^\Qpanc\E$/ } @pantry; print "$total";

      Here its showing error. Cant use Barewords Panc at 9

        Instead of
        any { Panc }

        use

        any { /^\QPanc\E$/ }

        the same way you would do with grep.

        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ