in reply to grep {CONSTANT} @list
Nothing to do with grep in particular, or constants.
use constant REGEXP => qr(a); print grep { REGEXP } qw(a b c);
... is equivalent to:
my @tmp; foreach (qw(a b c)) { push @tmp, $_ if qr(a); } print @tmp;
See the problem now? if qr(a) is always true. if qr(anything) is always true.
Try:
print grep { $_ =~ REGEXP } @list;
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
|
---|
In Section
Seekers of Perl Wisdom