http://www.perlmonks.org?node_id=260934


in reply to Formatting an output with printf

you can specify the width of a "column":
Z:\>perl use strict; printf STDOUT "[%-20s] [%20s]\n", 1000 .. 1001; ^D [1000 ] [ 1001] Z:\>
HTH - be sure to check out this article by merlyn.

Replies are listed 'Best First'.
Re: Re: Formatting an output with printf
by TVSET (Chaplain) on May 27, 2003 at 09:02 UTC
    If you want to be strict about your columns, then you might need to trancate strings if they are longer than the width of the column. Your example can be changed like this:

    Z:\>perl use strict; printf STDOUT "[%-20.20s] [%20.20s]\n", 1000 .. 1001; ^D [1000 ] [ 1001] Z:\>

    Leonid Mamtchenkov aka TVSET