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

Re: Looping through an Array

by toolic (Bishop)
on Jan 11, 2013 at 13:21 UTC ( #1012886=note: print w/ replies, xml ) Need Help??


in reply to Looping through an Array

You should dereference your array refs:

use warnings; #use strict; $colnames = [ 'MEASURE', 'CNT' ]; $arrref = [ [ '# PLTADM Queries (ex batch) ', '0' ] ]; my @colnames = @{ $colnames }; print "A size:" . @colnames . "\n"; for ($i=0; $i < @colnames; $i++) { print "A: " . $i . " : " . $colnames[$i] ."\n"; } for ($i=0; $i<= @arrref; $i++) { print "B size:" . @{$arrref->[$i]} . "\n"; for ($j=0; $j< @{$arrref->[$i]}; $j++) { print "B: " . $i . " : " . $j . " : " . $arrref->[$i]->[$j] . +"\n"; } } __END__ A size:2 A: 0 : MEASURE A: 1 : CNT B size:2 B: 0 : 0 : # PLTADM Queries (ex batch) B: 0 : 1 : 0

Tip #1 from the Basic debugging checklist: strict. See also:


Comment on Re: Looping through an Array
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2015-07-30 10:54 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 (271 votes), past polls