I found a guilty line. :)
# 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}); } }
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:
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; } }

In reply to Re: Printf with a minimum width. by Zaxonxp
in thread Printf with a minimum width. by Zaxonxp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.