in reply to Printf with a minimum width.
I was getting warnings, so I tough that I will initialize the hash value here. But this made the reset of the $len{$att} each time the new key from %data was analyzed. So I removed the line and put this instead:# count length of the strings my %len; foreach $nr (keys %data) { foreach my $att (@attr) { $len{$att} = 0; # <====== here update_max(%len, $att, $data{$nr}{$att}); } }
sub update_max(\%$$) { my ($ref_data, $att, $val) = @_; if (! $ref_data->{$att} ) { $ref_data->{$att} = 0; } my $siz = $ref_data->{$att}; my $siz2 = length($val); if ($siz < $siz2) { $ref_data->{$att} = $siz2; } }
|
|---|