# devel.pl
use Devel::Peek;
my $a = undef;
Dump $a;
my $b = \$a;
Dump $a; # note the reference count for $a
####
c:>perl -d devel.pl
Loading DB routines from perl5db.pl version 1.23
Editor support available.
Enter h or `h h' for help, or `perldoc perldebug' for more help.
main::(devel.pl:3): my $a = undef;
DB<1> n
main::(devel.pl:4): Dump $a;
DB<1> n
SV = NULL(0x0) at 0x1829ce0
REFCNT = 1
FLAGS = (PADBUSY,PADMY)
main::(devel.pl:5): my $b = \$a;
DB<1> n
main::(devel.pl:6): Dump $a;
DB<1> n
SV = NULL(0x0) at 0x1829ce0
REFCNT = 2 ###<----- correct count
FLAGS = (PADBUSY,PADMY)
####
c:>perl -de 1
Loading DB routines from perl5db.pl version 1.23
Editor support available.
Enter h or `h h' for help, or `perldoc perldebug' for more help.
main::(-e:1): 1
DB<1> use Devel::Peek;
DB<2> my $a = undef;
DB<3> Dump $a;
SV = NULL(0x0) at 0x1aeccfc
REFCNT = 1
FLAGS = ()
DB<4> my $b = \$a;
DB<5> Dump $a;
SV = NULL(0x0) at 0x1aeccfc
REFCNT = 1 ###<----- wrong reference count
FLAGS = ()
####
c:>perl -de 1
Loading DB routines from perl5db.pl version 1.23
Editor support available.
Enter h or `h h' for help, or `perldoc perldebug' for more help.
main::(-e:1): 1
DB<1> use Devel::Peek;
DB<2> $a = undef;
DB<3> Dump $a;
SV = NULL(0x0) at 0x1aecc18
REFCNT = 1
FLAGS = ()
DB<4> $b = \$a;
DB<5> Dump $a;
SV = NULL(0x0) at 0x1aecc18
REFCNT = 2 ###<--------correct here
FLAGS = ()