in reply to Creating Reports with hashes: Use of uninitialized value while adding integers
You need to change:
for my $size (@sizeOfTrees) { my $quant = $tree_collection{$years}{$trees}{$size} || "-" +; printf "%9s", "$quant"; # { no warnings; $total += $quant; } # WHY DO I NEED TH +IS? }
To:
for my $size (@sizeOfTrees) { my $quant = $tree_collection{$years}{$trees}{$size} || 0; printf "%9s", $quant || '-'; $total += $quant; }
my $quantity = (); my $total_quantity = (); my $total = (); my $year_total = ();
Why are you trying to assign a list to a scalar variable? Don't do that, it makes no sense!
printf "%9s", "$quant"; printf "%5s", "$total"; printf "%9s", "$total_col{$i}"; printf "%5s", "$year_total";
Don't quote scalar variables. Perl is not a shell! What's wrong with always quoting "$vars"?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Creating Reports with hashes: Use of uninitialized value while adding integers
by ikegami (Patriarch) on Jan 26, 2012 at 18:20 UTC | |
|
Re^2: Creating Reports with hashes: Use of uninitialized value while adding integers
by GertMT (Hermit) on Jan 26, 2012 at 16:31 UTC | |
by ikegami (Patriarch) on Jan 26, 2012 at 18:14 UTC |