Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Dereference array of arrays

by kennethk (Abbot)
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 drinking their drinks and smoking their pipes about the Monastery: (17)
As of 2015-07-28 16:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls