Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Formatting an output with printf

by kabel (Chaplain)
on May 27, 2003 at 04:39 UTC ( #260934=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: Formatting an output with printf
Download Code
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://260934]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-09-23 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (210 votes), past polls