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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.