in reply to Re^2: Why is Dumper returning "!!1" for true file test?
in thread Why is Dumper returning "!!1" for true file test?

I'm not aware of a single perldoc discussing all details, like it's done in MDN for JS.

(Especially as it's mostly internal stuff which could change and the effects are supposed to be DWIM. Like I said most problems arise when converting to other languages, esp. JS)

But you can gather them from various places like perlop or perlglossary .

FWIW and I don't think !!1 used to be dualvar (see Scalar::Util ) prior to 5.36.

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

Replies are listed 'Best First'.
Re^4: Why is Dumper returning "!!1" for true file test?
by ikegami (Patriarch) on Jan 22, 2024 at 02:53 UTC

    FWIW and I don't think !!1 used to be dualvar (see Scalar::Util ) prior to 5.36.

    It's actually a triplevar, and it has been so at least as far back as 5.6, but probably a lot further back.

    I don't have 5.6, but here's 5.8.9:

    $ 5.8.9/bin/perl -MDevel::Peek -e'Dump(!!1)' SV = PVNV(0x55e2de0d1348) at 0x55e2dd477310 REFCNT = 2147483647 FLAGS = (IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0x55e2de0d2320 "1"\0 CUR = 1 LEN = 8 $ 5.8.9/bin/perl -MDevel::Peek -e'Dump(!!0)' SV = PVNV(0x55aeb71e8320) at 0x55aeb5e05da0 REFCNT = 2147483647 FLAGS = (IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK) IV = 0 NV = 0 PV = 0x55aeb71e8300 ""\0 CUR = 0 LEN = 8
      In the case of !!1 it seems to only be just a performance thing, because all values are just 1 , i.e. any later casting would produce the same effect/caching of types.

      I was confused because prior to this I only heard of !!0 as dualvar and I'm kinda sure I read it in the perldocs.

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

        In the case of !!1 it seems to only be just a performance thing

        I think so. It is slightly different — I can get pPOK+pIOK+pNOK, but I can't also get IOK+NOK+POK — so there could be difference, but I don't know of any.