chakreey has asked for the wisdom of the Perl Monks concerning the following question:
I have a very basic query on finding number of elements in an array from array reference.
my @sss = ("1","3","4"); my $reee = []; for $entry (@sss){ push (@$reee, $entry);} my $asdad = length @$reee; print "$asdad";
Assuming, I don't know number of elements in @sss, How to find number of elements form @$reee.
Command "length @$reee" returns value 1, which is right, because it is a scalar. But I want to obtain result as 3. How to get it ?
Update: got it ! Array reference (@$ree) should be considered as array.
my $asdad = @$ressin line line 5 of code will give correct result !
Thanks every one
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to find number of elements of an array from array reference
by moritz (Cardinal) on Apr 07, 2011 at 14:41 UTC | |
|
Re: How to find number of elements of an array from array reference
by jpl (Monk) on Apr 07, 2011 at 15:15 UTC | |
|
Re: How to find number of elements of an array from array reference
by Marshall (Canon) on Apr 07, 2011 at 15:57 UTC | |
|
Re: How to find number of elements of an array from array reference
by Nikhil Jain (Monk) on Apr 07, 2011 at 16:16 UTC | |
by chromatic (Archbishop) on Apr 07, 2011 at 17:30 UTC | |
by jpl (Monk) on Apr 07, 2011 at 18:02 UTC | |
by chromatic (Archbishop) on Apr 07, 2011 at 21:41 UTC |