[EMAIL PROTECTED] wrote:
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 [EMAIL PROTECTED];
print [EMAIL PROTECTED];
print [EMAIL PROTECTED];
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
I am not sure if this is what you want, but try this,
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my @testarray=( [5, [1,3,18,21]], [16, [1,2,3]], [21, [1]]);
print Dumper(@testarray);
print "$testarray[0][0]\n"; #first number which is 5
print "$testarray[0][1][0]\n";#first number which is 1
print "@{$testarray[0][1]}\n";#prints entire first VAR, which is 5 , 1,
3 , 18 , 21
[EMAIL PROTECTED] tmp]# ./!$
././././././././././././././././././somebody.pl
$VAR1 = [
5,
[
1,
3,
18,
21
]
];
$VAR2 = [
16,
[
1,
2,
3
]
];
$VAR3 = [
21,
[
1
]
];
5
1
1 3 18 21
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/