in reply to Dereferencing an arrayref of arrayrefs

Thanks Monks. That was a lot of help and solved at least one part of the problem. However, I am still having some trouble with accessing only particular columns in the AoA. I want to do something like
for ($i=0; $i<10; $i++) {print $data[1][$i]; }
I know the syntax I've written here is not perfect. I've just kind of translated the logic into Perl to illustrate what I am getting at. So, can you tell me how do I go about doing this? Update: Ok never mind. I figured it out finally. Thanks for pointing out the relevant help docs. They helped!

Replies are listed 'Best First'.
Re^2: Dereferencing an arrayref of arrayrefs
by GrandFather (Saint) on Feb 01, 2010 at 01:18 UTC

    That would be better written:

    for my $index (0 .. 9) { print $data[1][$index]; }

    or if you want to print all the elements in the array reference you could:

    for my $index (0 .. $#{$data[1]}) { print $data[1][$index]; }

    or better still:

    for my $element (@{$data[1]}) { print $element; }

    and more succinctly as:

    print $_ for @{$data[1]};

    and if you would like a space between elements you can:

    print "@{$data[1]}";

    True laziness is hard work