In the Perl Debugger a variable $vc looks like this:
DB<1> p $vc
ARRAY(0x19d1f9c)
DB<2> x $vc
0 ARRAY(0x19d1f9c)
0 ARRAY(0x19e0694)
0 2.0
1 3.0
1 ARRAY(0x19e064c)
0 7.0
1 6.0
2 ARRAY(0x19e067c)
0 8.0
1 12.0
This tells you that $vc is a reference to an array. The array that
$vc references contains three elements. Each of those elements are
also references to arrays. The arrays that *those* references
reference contain two elements each, all numbers.
Please see:
perldoc perlreftut
How to I get :
2 3
7 6
8 12
Step by step:
$vc is a reference to an array
@{$vc} is the array that $vc references
${$vc}[0] is the first element of @{$vc}
The arrow rule lets us write that as $vc->[0]
$vc->[0] is also a reference to an array.
@{$vc->[0]} is the array that $vc->[0] references. This array
contains (2, 3);
So you could do a loop like the following:
foreach my $ref (@{$vc}) {
#here, $ref is one of the "inner" references
foreach my $elem (@{$ref}) {
print "$elem ";
}
print "\n";
}
Once you understand the above, you can make it much more concise:
foreach my $ref (@$vc) {
print "@{$ref}\n";
}
Hope this helps,
Paul Lalli
P.S. The final example presumes you've not mucked with the $"
variable.