in reply to "" but true

$ perl -M5.010 -e' package Crazy { use overload bool => sub { 1 }, q{""} => sub { "" }, fallback => 1; } my $x = bless({}, Crazy::); say $x ? "true" : "false"; say length($x); ' true 0

But don't. Just don't. If you think non-printable characters are confusing, this is next level confusing. This is an XY Problem.

(U+FEFF ZERO WIDTH NO-BREAK SPACE would be a better choice than NUL, not that you should use that solution either.)

Seeking work! You can reach me at

Replies are listed 'Best First'.
Re^2: "" but true
by Chuma (Scribe) on May 13, 2021 at 20:35 UTC
    Truly great and terrifying!
Re^2: "" but true
by Bod (Deacon) on May 13, 2021 at 23:13 UTC

    That really shouldn't be allowed...

    The fact that it is, is what makes Perl so wonderful and bizarre at the same time in a sort of perfect mix!

      > That really shouldn't be allowed...

      That's not true.

      For instance overloads are great when designing internal DSLs.

      These are embedded mini-languages which are meant to operate in very special semantics.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        I wasn't being totally serious...
        ...but I think you know that LanX 😜