in reply to How do I test if an array is empty or not?
or to put it in common perl termsmy $j = 0; for (my $i = 0; $i <= $#array; ++$i) { $current = $array[$i]; if($current == undef) { push @empty, $j++; } } print "undefined indices: @empty \n";
my @empties = (); for my $i(0..$#array) { unless(defined $array[$i]) { push @empties, $i; } } print "undefined indices @empties\n";
{Editor's note: This example doesn't work as the poster thought it would. See Abigail-II's explanation here: Re: Answer: How do I test if an array is empty or not?.}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Answer: How do I test if an array is empty or not?
by Abigail-II (Bishop) on Aug 21, 2002 at 11:09 UTC |