[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: exists $foo[7] and delete $foo[7]
delete on an array index should remove that index from the array,
such that the array is shorter.
these two snippets of pseudo-code should print out the same number,
but if delete(array_index) only sets the value to undef, they will
print out different values.
my %hash = {name=>'luke', occupation=>'jedi');
delete('name');
my @hash_keys=keys( %hash );
print scalar(@hash_keys);
1
my @array = ( luke, jedi );
delete(0);
my @array_keys=keys( @array );
print scalar(@array_keys);
2
if this happens, there is a strangeness introduced into perl
that gives inconsistent behaviour depending on whether you
are playing with a hash or an array.
Greg
- Follow-Ups from:
-
Larry Wall <larry@wall.org>
Nick Ing-Simmons <nick@ing-simmons.net>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]