in reply to Re: Easy Reference for Contexts
in thread Easy Reference for Contexts
For instance I doubted that scalar m// returns true or false (those identifiers don't exist in Perl), I thought it's the number of matches returned.Anything in Perl is true or false. Or rather, ANYTHING is true but undef is false. 😋But I was wrong: :)
DB<23> $_="aaa" DB<24> print scalar m/a/ 1
Like the relops, m//, s///, and y/// can all return the magical false value, that secret special value that nobody talks about:
% perl -wle 'printf "got %d matches\n", scalar ANYTHING =~ /nothing/'So I shan’t, either. 😜
got 0 matches
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Easy Reference for Contexts
by LanX (Saint) on Apr 15, 2011 at 10:11 UTC | |
by JavaFan (Canon) on Apr 15, 2011 at 10:48 UTC | |
by LanX (Saint) on Apr 15, 2011 at 11:14 UTC |