I thought I'd read that perl does sparse arrays. So under what conditions does that happen? This simple test shows that @ary becomes a 1001 element array through this simple slice assignment. Perhaps related is that the uninitialized elements have the READONLY flag set which initialized yet undefined elements don't have. And then there's the super-wacky REFCNT value. I'd think that the READONLY flag is used by exists() and delete() but this code doesn't test that guess. Care to spread some enlightenment about sparse arrays and maybe the other part as well?
use Devel::Peek; @ary[1,100,500,1000] = (); DumpArray(@ary); __DATA__ .... Elt No. 998 0x4284 SV = NULL(0x0) at 0x4284 REFCNT = 2147483634 FLAGS = (READONLY) Elt No. 999 0x106d0 SV = NULL(0x0) at 0x106d0 REFCNT = 1 FLAGS = ()
In reply to Sparse arrays? by diotalevi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |