NeilHeller has asked for the wisdom of the Perl Monks concerning the following question:
I would appreciate any help anyone can give.
This snippet below has a scalar reference pointing to an array. The second member of the array is a reference pointing to another array.
The code in question is:After this line executes, my debugger says that $array_size is now an array, not a scalar holding the length of the array. Why???$aray_size = scalar (@$states[ 1 ]);
my $states = [ ]; # Annonymous array constructed push @$states, 'Oregon'; print "@$states [ 0 ]\n"; my $city; my $cities = [ ]; # Inner annonymous array constructed push @$cities, "Portland"; push @$cities, "Salem"; push @$cities, "Bend"; push @$states, $cities; my $counter; my $array_size = scalar (@$states [ 1 ]); # here for ($counter = 0; $counter < $array_size; $counter++) { print "\t@$states [ 1 ]->\[$counter\]\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Changling here?
by GrandFather (Saint) on May 30, 2008 at 02:53 UTC | |
|
Re: Changling here?
by jdporter (Paladin) on May 30, 2008 at 02:58 UTC | |
|
Re: Changling here?
by hangon (Deacon) on May 30, 2008 at 03:33 UTC | |
by GrandFather (Saint) on May 30, 2008 at 03:41 UTC |