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
In reply to Re^2: Easy Reference for Contexts
by tchrist
in thread Easy Reference for Contexts
by cat_baby
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |