Cybris has asked for the wisdom of the Perl Monks concerning the following question:
This prints the number 4, although @a should only have 3 elements. It seems that $a[3] is created on the fly while reading it. I would of course understand this if I assigned a value to $a[3]{foo}, but here I am only reading - which should be non-destructive (or non-constructive, for that matter). I humbly beg for enlightenment...my @a = ( {}, {}, {} ); print $a[3]{foo}; print scalar @a . "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange behaviour reading from hashref stored in array
by moritz (Cardinal) on Feb 16, 2009 at 15:00 UTC | |
|
Re: Strange behaviour reading from hashref stored in array
by Random_Walk (Prior) on Feb 16, 2009 at 15:36 UTC | |
|
Re: Strange behaviour reading from hashref stored in array
by Narveson (Chaplain) on Feb 16, 2009 at 15:01 UTC |