Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Looping through an Array

by toolic (Chancellor)
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 browsing the Monastery: (7)
As of 2014-08-23 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (173 votes), past polls