Try this:
use Devel::Peek;
...
sub save {
Dump $_[0];
push(@savearr, \$_[0]);
readonly_on(${$savearr[-1]});
Dump ${$savearr[-1]};
}
...
__END__
SV = PV(0x75cbc8) at 0x88d238 #
REFCNT = 1
FLAGS = (PADTMP,POK,pPOK)
PV = 0x77e340 "begin 0 end"\0
CUR = 11
LEN = 16
SV = PV(0x75cc68) at 0x75ef48
REFCNT = 1
FLAGS = (POK,READONLY,pPOK)
PV = 0x77e940 "begin 0 end"\0
CUR = 11
LEN = 16
SV = PV(0x75cbc8) at 0x88d238 #
REFCNT = 1
FLAGS = (PADTMP,POK,pPOK)
PV = 0x77e340 "begin 1 end"\0
CUR = 11
LEN = 16
SV = PV(0x75cce8) at 0x7836b8
REFCNT = 1
FLAGS = (POK,READONLY,pPOK)
PV = 0x78cc60 "begin 1 end"\0
CUR = 11
LEN = 16
SV = PV(0x75cbc8) at 0x88d238 #
REFCNT = 1
FLAGS = (PADTMP,POK,pPOK)
PV = 0x77e340 "begin 2 end"\0
CUR = 11
LEN = 16
SV = PV(0x75ccf8) at 0x783700
REFCNT = 1
FLAGS = (POK,READONLY,pPOK)
PV = 0x87bb70 "begin 2 end"\0
CUR = 11
LEN = 16
SV = PV(0x75cbc8) at 0x88d238 #
REFCNT = 1
FLAGS = (PADTMP,POK,pPOK)
PV = 0x77e340 "begin 3 end"\0
CUR = 11
LEN = 16
SV = PV(0x75cd08) at 0x783748
REFCNT = 1
FLAGS = (POK,READONLY,pPOK)
PV = 0x87bcd0 "begin 3 end"\0
CUR = 11
LEN = 16
$VAR1 = [
\'begin 0 end',
\'begin 1 end',
\'begin 2 end',
\'begin 3 end'
];
Note that the marked instances are in fact the same scalar. A new one isn't created before pushing it onto the array.