in reply to File write problem
You should read the documentation for printf/sprintf. It's unreasonable for you to expect that it will magically interpolate the variables into their values for the desired width. You need to tell it the width you want. For example:
printf "%-15.15s % 4d\n", $string, $integer;
This code tells printf to format the $string variable into a 15 character column, left justifying it (and truncating it if it's too long. It formats $integer into a 4 character field, filling with spaces.
...roboticus
Update: Cleaned up the formatting. (Thanks, moritz!)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: File write problem
by perl_seeker (Scribe) on Aug 03, 2010 at 12:05 UTC |