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

Re: Filling a matrix

by Athanasius (Archbishop)
on Aug 08, 2014 at 12:20 UTC ( [id://1096750]=note: print w/replies, xml ) Need Help??


in reply to Filling a matrix

Hello David92,

The main problem is this line:

@valueArray = ([$version,$totSP]);

which simply overwrites the whole array on each iteration of the innermost loop. Replace it with this:

push @valueArray, [$version, $totSP];

Also, please put

use strict; use warnings;

at the head of your script, and declare all variables explicitly as lexicals by using my:

for my $folderId (keys %hash) { for my $customer (keys %{$hash{$folderId}}) { for my $version (keys %{$hash{$folderId}{$customer}}) { my $totSP = $hash{$folderId}{$customer}{$version}{totSP}; push @valueArray, [$version, $totSP]; } } }

— and note how much easier it is to read code which is indented consistently. ;-)

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-26 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found