[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: exists $foo[7] and delete $foo[7]
Tom Christiansen writes:
: >> I like the potential, but the well- (and strictly-) defined linear
: >> nature of arrays will lead people to believe things like:
: >>
: >> $a[100] = '0-99 do not yet exist';
: >> # later in their code...
: >> exists $a[23] or die "Why not? \$a[100] exists!";
:
: >Funny, I am always wondering why perl suddenly claims there are 101
: >elements when I'm fairly sure I've only set 1.
:
: Funny, I don't recall Perl ever saying that.
Sure it does, if you say scalar(@a). But then scalar(%a) is also
strange, so it fits. You have to use keys(@a) to find that actual
number of existing elements.
Larry
- References to:
-
Tom Christiansen <tchrist@chthon.perl.com>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]