Subject: | eq_array changes the magic nature of the "expected" array |
When comparing an input array with magic values to a fiducial array
without, eq_array transfers magic to the fiducial array. Here's an
example using YAML (which creates a magic value):
use YAML;
use Devel::Peek;
use Test::More;
my $obj = [ 'snake' ];
YAML::DumpFile( 'foo', $obj );
Dump $obj;
my $array = YAML::LoadFile( 'foo' );
eq_array( $array, $obj );
Dump $obj;
And the result:
% perl eq_array.pl
SV = RV(0xe4d660) at 0xe4d650
REFCNT = 1
FLAGS = (PADMY,ROK)
RV = 0xe21df0
SV = PVAV(0xe22fb0) at 0xe21df0
REFCNT = 1
FLAGS = ()
ARRAY = 0xe396b0
FILL = 0
MAX = 0
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = PV(0xe1eb68) at 0xe22060
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0xe35560 "snake"\0
CUR = 5
LEN = 8
SV = RV(0xe4d660) at 0xe4d650
REFCNT = 1
FLAGS = (PADMY,ROK)
RV = 0xe21df0
SV = PVAV(0xe22fb0) at 0xe21df0
REFCNT = 1
FLAGS = (RMG)
MAGIC = 0x1032e00
MG_VIRTUAL = &PL_vtbl_arylen_p
MG_TYPE = PERL_MAGIC_arylen_p(@)
MG_FLAGS = 0x02
REFCOUNTED
MG_OBJ = 0x1520110
SV = PVMG(0x1124160) at 0x1520110
REFCNT = 1
FLAGS = (GMG,SMG,pIOK)
IV = 0
NV = 0
PV = 0
MAGIC = 0x152bd10
MG_VIRTUAL = &PL_vtbl_arylen
MG_TYPE = PERL_MAGIC_arylen(#)
MG_OBJ = 0xe21df0
ARRAY = 0xe396b0
FILL = 0
MAX = 0
ARYLEN = 0x1520110
FLAGS = (REAL)
Elt No. 0
SV = PV(0xe1eb68) at 0xe22060
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0xe35560 "snake"\0
CUR = 5
LEN = 8
I believe $obj should remain unchanged. The fallout from this is that
Clone, which doesn't seem to be able to clone the YAML created hash,
also doesn't work on $obj.
Thanks,
Diab