diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2009-03-17 15:34:24 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2009-03-17 15:34:24 +0100 |
commit | 168ff818262576c8ec771f99cf50b7095a83e10c (patch) | |
tree | 7d7f80fecbc6e55f998f7b6a5a7359d07aa082ed /pod/perlsyn.pod | |
parent | 203d1e89388de309200a88815a95943bd5b59d86 (diff) | |
download | perl-168ff818262576c8ec771f99cf50b7095a83e10c.tar.gz |
Document that empty sets don't smart-match
(and implement this for the C<~~ coderef> form)
Diffstat (limited to 'pod/perlsyn.pod')
-rw-r--r-- | pod/perlsyn.pod | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod index 2e1f4c57d2..52a3f87c24 100644 --- a/pod/perlsyn.pod +++ b/pod/perlsyn.pod @@ -683,42 +683,43 @@ entries apply in those cases. (overloading trumps everything below) - Hash CodeRef sub truth for each key !grep { !$b->($_) } keys %$a - Array CodeRef sub truth for each elt !grep { !$b->($_) } @$a - Any CodeRef scalar sub truth $b->($a) + Hash CodeRef sub truth for each key[1] !grep { !$b->($_) } keys %$a + Array CodeRef sub truth for each elt[1] !grep { !$b->($_) } @$a + Any CodeRef scalar sub truth $b->($a) Hash Hash hash keys identical [sort keys %$a]~~[sort keys %$b] Array Hash hash slice existence @$a == grep {exists $b->{$_}} @$a - Regex Hash hash key grep grep /$a/, keys %$b + Regex Hash hash key grep[1] grep /$a/, keys %$b undef Hash always false (undef can't be a key) Any Hash hash entry existence exists $b->{$a} - Hash Array hash slice existence @$b == grep {exists $a->{$_}} @$b - Array Array arrays are comparable[1] - Any Array match against an array element[2] + Hash Array hash slice existence[1] @$b == grep {exists $a->{$_}} @$b + Array Array arrays are comparable[2] + Any Array match against an array element[3] grep $a ~~ $_, @$b Hash Regex hash key grep grep /$b/, keys %$a Array Regex array grep grep /$b/, @$a Any Regex pattern match $a =~ /$b/ - Num Range[3] in numeric range - undef Range[3] always false - Any Range[3] in string range + Num Range[4] in numeric range + undef Range[4] always false + Any Range[4] in string range - Num numish[4] numeric equality $a == $b + Num numish[5] numeric equality $a == $b Any Str string equality $a eq $b Any Num numeric equality $a == $b Any Any string equality $a eq $b - 1 - that is, each element matches the element of same index in the other - array. [2] - 2 - If a circular reference is found, we fall back to referential equality. - 3 - a range is written EXPR..EXPR (using the C<..> range operator, but + 1 - empty hashes or array won't match. + 2 - that is, each element matches the element of same index in the other + array. [3] + 3 - If a circular reference is found, we fall back to referential equality. + 4 - a range is written EXPR..EXPR (using the C<..> range operator, but NOT the three-dot version C<...>, which will be treated as a boolean operator) - 4 - either a real number, or a string that looks like a number + 5 - either a real number, or a string that looks like a number The "matching code" doesn't represent the I<real> matching code, of course: it's just there to explain the intended meaning. Unlike |