> -----Original Message-----
> From: Heiko Heggen [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 29, 2002 5:48 AM
> To: [EMAIL PROTECTED]
> Subject: Formatting String output
> 
> 
> Hi Guys.
> 
> I want to format my String output with the 'printf' command, 
> but I cant find
> the solution. For you experienced people this is not problem 
> I think, so
> could you give me the right hint, please
> 
> What I want to do:
> I have several arrays which contains a certain number of strings with
> different length. And I want to generate an output like this:
> 
> asdfg  a      as     asdf
> as     asdf   asdfgh a
> asdf   asdfg  a      asdfgh
> 
> I think this is something like that:
> for ($i=0; $i<$arrayCount; $i++)
> { printf("%s", myArray[$i]:10); }
> 
> But this does not work. Where is the fault.

All the details are in:

   perldoc -f sprintf

To output in a field of 10 cols:

   printf('%10s', 'Hello'); 
   # prints '     Hello'

Default is right-justified. To left-justify:

   printf('%-10s', 'Hello'); 
   # prints 'Hello     '

Default is to expand the field if input is longer. To
truncate to exactly 10 chars (and left-justify):

   printf('%-10.10s', 'ARatherLongString'); 
   # prints 'ARatherLon'

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to