Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Dereference array of arrays

by kennethk (Monsignor)
on Nov 12, 2013 at 15:20 UTC ( #1062215=note: print w/ replies, xml ) Need Help??


in reply to Dereference array of arrays

A little off-topic, but you should be aware that $a and $b are special variables associated with sort. It's generally considered risky/poor-form to use them outside of that context. Just to help you avoid developing bad habits.

To answer your original question, you could modify your posted code to get

while (@AoA) { my $var = shift @AoA; my $a = $var->[1]; my $b = $var->[2]; }
or
while (@AoA) { my $var = shift @AoA; my ($a, $b) = @{$var}[1,2]; }
or
while (@AoA) { my @var = @{shift @AoA}; my $a = $var[1]; my $b = $var[2]; }
or
for my $i (0 .. $#AoA) { my $a = $AoA[$i][1]; my $b = $AoA[$i][2]; }
or...

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


Comment on Re: Dereference array of arrays
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1062215]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-10-25 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (138 votes), past polls