in reply to Re^6: perl5.10 Devel::Size behaviour changed? (reason for magic)
in thread perl5.10 Devel::Size behaviour changed?

Commits 02d85cc37a4acecafdc2f0b45640b03cd1f4ac71 and 28c5b5bcd7f52e6b2219508a1066cd0ccc8dd19a fix this when $#array is used as a rvalue. You'll see these changes in 5.11.2 (next month's dev release) and 5.12 (early to mid 2010)
  • Comment on Re^7: perl5.10 Devel::Size behaviour changed? (reason for magic)

Replies are listed 'Best First'.
Re^8: perl5.10 Devel::Size behaviour changed? (reason for magic)
by BrowserUk (Patriarch) on Oct 28, 2009 at 19:29 UTC

      Oops, I forgot what this thread was really about when I posted. $#array is fixed. AvARYLEN isn't changed. AvARYLEN doesn't exist as a field, so don't try to measure its size. The following code shouldn't be executed in 5.10+:

      if (AvARYLEN(thing)) { if (check_new(tv, AvARYLEN(thing))) { total_size += thing_size(AvARYLEN(thing), tv); } }

      Test with bleadperl and with those lines present:

      perl -MDevel::Peek -MDevel::Size=total_size -wle' my @a = qw( a b c ); Dump(\@a,1); # Shows no magic print total_size \@a; # 224 Dump(\@a,1); # Shows magic $#a=$#a; # Add magic Dump(\@a,1); # Shows magic print total_size \@a; # 224 '

      Test with bleadperl and with those lines commented out:

      perl -MDevel::Peek -MDevel::Size=total_size -wle' my @a = qw( a b c ); Dump(\@a,1); # Shows no magic print total_size \@a; # 168 Dump(\@a,1); # Shows no magic $#a=$#a; # Add magic Dump(\@a,1); # Shows magic print total_size \@a; # 224 '

      Update: Fixed reply to reflect the actual usage of AvARYLEN by the module. It's not used to determine the length of arrays as I had originally indicated.

      Update: Added tests.