Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: defined defined -- Bug or "Feature"?

by GrandFather (Sage)
on Dec 24, 2015 at 07:56 UTC ( #1151098=note: print w/replies, xml ) Need Help??


in reply to defined defined -- Bug or "Feature"?

The most likely answer is that defined returns an empty string as a false value. An empty string is defined so the left most defined sees a defined value - the result from the right most defined.

So, not really a bug, just an interesting edge case.

Premature optimization is the root of all job security
  • Comment on Re: defined defined -- Bug or "Feature"?

Replies are listed 'Best First'.
Re^2: defined defined -- Bug or "Feature"?
by Anonymous Monk on Dec 24, 2015 at 08:33 UTC
    Probably not, Pl_sv_false ought to be same as undef, there were some bugs regarding this, but i'm afk & my mem is fuzzy. Devel::Peek...:)
      PL_sv_undef, PL_sv_no and PL_sv_yes are three distinct values with distinct properties. Only PL_sv_undef is undef.

      Dave.

        indeed :)
        #!/usr/bin/perl -- use Devel::Peek qw/ Dump /; select STDERR; print "\n\$ARGV\n"; Dump( $ARGV ); print "\nundef\n"; Dump( undef ); print "\n!!0 PL_sv_no\n"; Dump( !!0 ); print "\ndefined undef\n"; Dump( defined undef ); print "\n!!1 PL_sv_yes\n"; Dump( !!1 ); print "\ndefined defined undef\n"; Dump( defined defined undef ); __END__
        
        $ARGV
        SV = NULL(0x0) at 0x99b90c
          REFCNT = 1
          FLAGS = ()
        
        undef
        SV = NULL(0x0) at 0x3f4cc0
          REFCNT = 2147482895
          FLAGS = (READONLY)
        
        !!0 PL_sv_no
        SV = PVNV(0x3f7f84) at 0x3f4968
          REFCNT = 2147483646
          FLAGS = (PADTMP,IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
          IV = 0
          NV = 0
          PV = 0x3f405c ""\0
          CUR = 0
          LEN = 12
        
        defined undef
        SV = PVNV(0x3f7f84) at 0x3f4968
          REFCNT = 2147483646
          FLAGS = (PADTMP,IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
          IV = 0
          NV = 0
          PV = 0x3f405c ""\0
          CUR = 0
          LEN = 12
        
        !!1 PL_sv_yes
        SV = PVNV(0x3f7f9c) at 0x3f4978
          REFCNT = 2147483643
          FLAGS = (PADTMP,IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
          IV = 1
          NV = 1
          PV = 0x3f8e7c "1"\0
          CUR = 1
          LEN = 12
        
        defined defined undef
        SV = PVNV(0x3f7f9c) at 0x3f4978
          REFCNT = 2147483643
          FLAGS = (PADTMP,IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
          IV = 1
          NV = 1
          PV = 0x3f8e7c "1"\0
          CUR = 1
          LEN = 12
        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1151098]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2020-01-25 18:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?