> -----Original Message----- > From: Scott [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, January 09, 2002 10:29 AM > To: [EMAIL PROTECTED] > Subject: Formatting with printf > > > Hi all..... > > I have a couple of strings that I need to format. One of > those fields is > a alpha/numeric string. Here is the code: > > printf NEWQUOTES ("%-5s", @fields[14]); > > When I run the code I get 10 extra spaces before the next > field instead of > the 5. The value of @fields[14] is: A2103. >
As an aside, you should use $fields[14], not @fields[14]. For an explanation of why, run your script like this: perl -Mdiagnostics -w myscript.pl >/dev/null But that's not explaining the spaces. If you are getting spaces printed after A2103, they must be in the value in $fields[14]. The width specifier of 5 sets only a minimum width, not a maximum. If you want exactly 5 columns to be output, with longer values truncated, you can use: %-5.5s > Is there a problem with the value being alpha/numeric? No. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]