Just to explain in more detail:
N:\>perl -MDevel::Peek -e"my @x=(1..2); Dump($x[0]); $y=join '-',@x; D +ump($x[0]); SV = IV(0x182b3e4) at 0x2257e8 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 1 SV = PVIV(0x225ef4) at 0x2257e8 REFCNT = 1 FLAGS = (IOK,POK,pIOK,pPOK) IV = 1 PV = 0x22d3fc "1"\0 CUR = 1 LEN = 2
The first shows $x[0] when its an SvIV. The second output is the same var after it has been stringified (which means its been "upgraded" to an SvPVIV). Note that there are now additional slots in the SV that are populated, containing such things as the stringified version of the integer,(PV) how long the string is, and how much of the allocated string is actually used. (LEN and CUR).
What this means is that if you want to avoid the problem simply use the form
print join map { "$_" },@list;
which will make the SV that gets upgraded be a temporary, leaving the original unchanged.
My guess why it hasnt come up before is that probably its unusual for such a large structure to contain only SvIV's. So under normal circumstance id guess that if an OOM error occured it occured while building the structure itself and not when it was printed out.
In reply to Re^2: Memory Error Printing Multiple Hashes Simultaneously
by demerphq
in thread Memory Error Printing Multiple Hashes Simultaneously
by bernanke01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |