in reply to Re: Printing the length of an array ?
in thread Printing the length of an array ?
The ++ makes the array one element longer, adding an undef at the end:
my @array = qw/1 2 3 4 5 6 7/; print "number of elements is " . ++$#array . "\n"; print Dumper \@array;
number of elements is 7 $VAR1 = [ '1', '2', '3', '4', '5', '6', '7', undef ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Printing the length of an array ?
by ww (Archbishop) on Mar 30, 2008 at 21:30 UTC | |
by chromatic (Archbishop) on Mar 30, 2008 at 21:57 UTC | |
by shmem (Chancellor) on Mar 30, 2008 at 22:08 UTC | |
by Not_a_Number (Prior) on Mar 30, 2008 at 22:38 UTC | |
by wardy3 (Scribe) on Mar 31, 2008 at 04:39 UTC |