From: Rafael Garcia-Suarez Date: Wed, 25 Mar 2009 22:55:34 +0000 (+0100) Subject: Adjustments to the ~~ dispatch table X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c3886e8b3633df50e9636123f8fe89c9e6378436;p=p5sagit%2Fp5-mst-13.2.git Adjustments to the ~~ dispatch table Hash slice existence now uses 'exists' instead of the complex recursive invocation to ~~. Any ~~ Array matches now keep the "any" element on the LHS of the smart match. More special cases have been added for complex values of "Any". --- diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod index f356d55..ba4ae2a 100644 --- a/pod/perlsyn.pod +++ b/pod/perlsyn.pod @@ -688,14 +688,17 @@ entries apply in those cases. Any CodeRef scalar sub truth $b->($a) Hash Hash hash keys identical [sort keys %$a]~~[sort keys %$b] - Array Hash hash slice existence grep $_ ~~ $b, @$a + Array Hash hash slice existence grep { exists $b->{$_} } @$a Regex Hash hash key grep 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 grep { exists $a->{$_} } @$b Array Array arrays are comparable[2] + Regex Array array grep grep /$a/, @$b + undef Array array contains undef grep !defined, @$b Any Array match against an array element[3] - grep $_ ~~ $a, @$b + grep $a ~~ $_, @$b Hash Regex hash key grep grep /$b/, keys %$a Array Regex array grep grep /$b/, @$a