Scott wrote:
>
> Hi all.....
Hello,
> 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.
printf is based on the C language printf function and can be a bit
tricky. The format "%-5s" will not truncate a value longer than 5
characters but it will pad a shorter value with spaces. To truncate a
longer value use the format "%-5.5s". Also, the variable @fields[14] is
an array slice, you want a scalar $fields[14].
printf( NEWQUOTES "%-5.5s", $fields[14] );
> Is there a problem with the value being alpha/numeric?
No.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]