in reply to Re^2: Can an element be created because it was accessed ?
in thread Can an element be created because it was accessed ?

That wont work if the array is intentionally sparse.

Depending on how the O.P enters data into the array, "defined" may be a reasonable choice.

            "Battle not with trolls, lest ye become a troll; and if you gaze into the Internet, the Internet gazes also into you."
        -Friedrich Nietzsche: A Dynamic Translation

  • Comment on Re^3: Can an element be created because it was accessed ?

Replies are listed 'Best First'.
Re^4: Can an element be created because it was accessed ?
by ikegami (Patriarch) on Dec 29, 2011 at 04:33 UTC

    That wont work if the array is intentionally sparse.

    This is not a supported "feature". It's the side effect of a bug in exists.

    But my fix was wrong. (I've been fixing uses of exists to check if an element exists.) It should be

    if ( defined( $this->{N}[$1] ) ) { my $testedNVal = $this->{N}[$1]{Val}; ... }

    And in all likelyhood, the following would also do the trick:

    if ( $this->{N}[$1] ) { my $testedNVal = $this->{N}[$1]{Val}; ... }