develooper Front page | perl.beginners | Postings from April 2008

Simple perl array question

Thread Next
From:
dfairman16
Date:
April 20, 2008 14:52
Subject:
Simple perl array question

Well simple if you are not learning Perl. You guessed it, I am a
newbie.

My question is if I have an array like this, actually it is my whole
program.

my @testarray=( [5, [1,3,18,21]], [16, [1,2,3]], [21, [1]]);
print #@$testarray[0][1];
print #@$testarray[1][1];
print #@$testarray[2][1];

What I had expected and what I want is to print out 4, 3, and 1 but it
prints out 1 and 1 and I don't know why. The 4,3, and 1 are the
lengths of the second array in the array of arrays.


If someone could put me right I can move on (to the next problem and
understanding your code).
Thank you
David


Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About