in reply to Re: printf question
in thread printf question
almut's right.
Mike
You can get a slight improvement by keeping track of your longest word as you count them, though, and then using printf's "*" modifier to read the field width from that variable.
I'd put a width specifier on the %d so the numbers line up nicely as well, but that's just my preference:printf "%-*s %d\n", $maxLen, $word, $seen{$word};
printf "%-*s %4d\n", $maxLen, $word, $seen{$word};
Mike
|
---|
In Section
Seekers of Perl Wisdom