in reply to Why is to match, not to match?

Maybe this will clarify things for you? (Hint: $a !~~ $b parses as $a !~ (~$b))

c:\test>perl -MO=Deparse use 5.10.0; use strict; use warnings (FATAL => 'all'); my $a = "hello"; my $b = "hello"; print "a matches b\n" if($a ~~ $b); print "a not matches b\n" if($a !~~ $b); print "a matches not b\n" if($a ~~! $b); print "a matches and a half b\n" if($a ~~~ $b); print "a not matches and a half b\n" if($a !~~~ $b); print "a double matches b\n" if($a ~~~~ $b); print "a not double matches b\n" if($a !~~~~ $b); ^Z sub BEGIN { require 5.10.0; } BEGIN {${^WARNING_BITS} = "\377\377\377\377\377\377\377\377\377\377\37 +7?"} use strict 'refs'; BEGIN { $^H{'feature_say'} = q(1); $^H{'feature_state'} = q(1); $^H{'feature_switch'} = q(1); } my $a = 'hello'; my $b = 'hello'; print "a matches b\n" if $a ~~ $b; print "a not matches b\n" if not $a =~ ~$b; print "a matches not b\n" if $a ~~ !$b; print "a matches and a half b\n" if $a ~~ ~$b; print "a not matches and a half b\n" if not $a =~ ~~$b; print "a double matches b\n" if $a ~~ ~~$b; print "a not double matches b\n" if not $a =~ ~~~$b; - syntax OK

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW It is as I've been saying!(Audio until 20090817)

Replies are listed 'Best First'.
Re^2: Why is to match, not to match?
by CRAKRJACK (Initiate) on Aug 28, 2009 at 18:44 UTC

    Yes, it does, thanks! .....except for this scary bit;

    print "a double matches b\n" if $a ~~ ~~$b; print "a not double matches b\n" if not $a =~ ~~~$b;

    That sounds like even perl does not know what it is doing!

    $a ==== $b
    would never make it past the censors, and it is telling us that it just successfully parsed a "match and a half" operator there?

      .....except for this scary bit;

      Not so scary once you realise that ~$b is bitwise-NOT of $b; and ~~$b is the bitwise-NOT of the bitwise-NOT of $b--which is just $b--and so on ad nauseum:

      c:\test>perl -E"$b = 'fred'; say for $b, ~$b, ~~$b, ~~~$b, ~~~~$b, ~~~ +~~$b" fred ÖìÜø fred ÖìÜø fred ÖìÜø
      That sounds like even perl does not know what it is doing!

      Perl knows! You just haven't been inducted into its inner circle yet:)


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.