in reply to Re^5: Minimisation of codes (if grep {})
in thread Minimisation of codes (if grep {})
#!/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 { /^\QPanc\E$/ } @pantry; #$total++ if grep { /^\Qpanc\E$/ } @pantry; print "$total";
Errors: Use of uninitialized value $_ in pattern match (m//) at /root/prac/CDR/tr.pl line 8. Can't locate object method "any" via package "Panc" (perhaps you forgot to load "Panc"?) at /root/prac/CDR/tr.pl line 8.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Minimisation of codes (if grep {})
by choroba (Cardinal) on Oct 01, 2015 at 12:14 UTC | |
by ravi45722 (Pilgrim) on Oct 01, 2015 at 12:28 UTC | |
by MidLifeXis (Monsignor) on Oct 01, 2015 at 14:09 UTC |