Estudie la siguiente ejecución con el depurador. El módulo Devel::Peek nos permite observar la estructura interna de las variables en el intérprete:
lhp@nereida:~/Lperl/src$ perl -MDevel::Peek -wd weakenwithcopy.pl
main::(weakenwithcopy.pl:3): my ($ref, $copy);
main::(weakenwithcopy.pl:4): {
DB<1> c 10
main::(weakenwithcopy.pl:10): print $$ref;
DB<2> -
1: use strict;
2: use Scalar::Util qw(weaken);
3: my ($ref, $copy);
4 {
5: my $var = "hola\n";
6: $ref = \$var;
7: weaken($ref);
8: $copy = $ref;
9 }
10==> print $$ref;
DB<2> Dump $ref
SV = RV(0x817b328) at 0x823a050
REFCNT = 2
FLAGS = (PADBUSY,PADMY,ROK,WEAKREF)
RV = 0x814f7e0
SV = PVMG(0x83dcb80) at 0x814f7e0
REFCNT = 1
FLAGS = (PADBUSY,PADMY,RMG,POK,pPOK)
IV = 0
NV = 0
PV = 0x8238fa8 "hola\n"\0
CUR = 5
LEN = 8
MAGIC = 0x83e3368
.............................
DB<3> Dump $copy
SV = RV(0x817b324) at 0x814f810
REFCNT = 2
FLAGS = (PADBUSY,PADMY,ROK)
RV = 0x814f7e0
SV = PVMG(0x83dcb80) at 0x814f7e0
REFCNT = 1
FLAGS = (PADBUSY,PADMY,RMG,POK,pPOK)
IV = 0
NV = 0
PV = 0x8238fa8 "hola\n"\0
CUR = 5
LEN = 8
MAGIC = 0x83e3368
.............................
Casiano Rodríguez León
