Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks,
I am having problems finding the real length of an array with null values at the right of the array:
returns:my @array = (1,2,3,4,5,6,7,8,9); my @array_2 = (1,2,3,4,5,6,7,8,9,,,,,,); print "Scalar of array 1 =",scalar @array,"\n"; print "Scalar of array 2 =",scalar @array_2,"\n";
Is there any way to get the real length of the array rather than the length up till the last non-empty field? Maybe something like the modifier to split:bash-2.03$ perl test.pl Scalar of array 1 =9 Scalar of array 2 =9 bash-2.03$
#split but do not toss out empty fields split ("\t",string,999999)
I appreciate the help,
Hackmare
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: find real length of an array
by merlyn (Sage) on Mar 16, 2003 at 15:59 UTC | |
by hackmare (Pilgrim) on Mar 16, 2003 at 16:51 UTC | |
by Aristotle (Chancellor) on Mar 16, 2003 at 19:04 UTC | |
by hackmare (Pilgrim) on Mar 16, 2003 at 22:37 UTC | |
|
Re: find real length of an array
by jand (Friar) on Mar 16, 2003 at 16:02 UTC | |
|
Re: find real length of an array
by pg (Canon) on Mar 16, 2003 at 18:24 UTC | |
by hackmare (Pilgrim) on Mar 16, 2003 at 22:43 UTC | |
|
Re: find real length of an array
by artist (Parson) on Mar 16, 2003 at 16:35 UTC | |
by hackmare (Pilgrim) on Mar 16, 2003 at 22:39 UTC | |
|
Re: find real length of an array
by hackmare (Pilgrim) on Mar 16, 2003 at 15:48 UTC |