in reply to how many elements in array?
my @a = (1, undef, 3); # Now scalar @a = 3, but there are only two elements of interest. # Brute force counting method: my $c = 0; $c++ for (grep { defined } @a); # $c now holds the number of defined elements, in this case 2.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how many elements in array?
by tlm (Prior) on Apr 18, 2005 at 16:54 UTC | |
by moot (Chaplain) on Apr 18, 2005 at 17:52 UTC |