http://qs321.pair.com?node_id=725444


in reply to Re^4: Could we save the memory occupied by "undef" in an array?
in thread Could we save the memory occupied by "undef" in an array?

Could you please explain the Dumper output if you have some free time?

By "I think" and "if I read what follows correctly", I meant to communicate that I'm not clear on the details relevant to this conversation. I've already described the relevant details beyond my understanding.

The only other relevant details might be FILL = 3 (4 elements are visible) and MAX = 3 (4 elements have been allocated). Perl sometimes allocate a larger array than it needs to speed up future push statements. It also has the option to speed up pop statements by not resizing the allocated block.

>perl -MDevel::Peek -le"@a=qw(a b c); Dump(\@a, 1); pop @a; Dump(\@a, +1)" SV = RV(0x183c550) at 0x2260b4 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x226dbc SV = PVAV(0x22bfcc) at 0x226dbc REFCNT = 2 FLAGS = () IV = 0 NV = 0 ARRAY = 0x1833fc4 FILL = 2 # 0..2 in use MAX = 3 # 0..3 allocated ARYLEN = 0x0 FLAGS = (REAL) SV = RV(0x183c550) at 0x2260a8 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x226dbc SV = PVAV(0x22bfcc) at 0x226dbc REFCNT = 2 FLAGS = () IV = 0 NV = 0 ARRAY = 0x1833fc4 FILL = 1 # 0..1 in use MAX = 3 # 0..3 allocated ARYLEN = 0x0 FLAGS = (REAL)

Would you mind if I request you to explain that?

Did you ask the same question twice, or is this a different "that"?