>The code
>
> #!perl -w
> $x = 0.061234567;
> $string = sprintf "%.2f\%", $x * 100;
>
>works fine ($string = 6.12%), but it produces an
>
> Invalid conversion in sprintf: end of string
>
>error message. Removing the -w flag eliminates the error message,
>but I don't understand why there is an error at all. Obviously "\%"
>is the source of the error, but why should this literal %-sign cause
>a problem?
>
>I'm not interested in a get-around. The line
>
> $string = sprintf( "%.2f", $x * 100 ) . '%';
>
>works fine. I'm just curious as to why the first form results in an
>error message.
Because that's not the way you get a literal % into a sprintf format string:
#!perl -w
$x = 0.061234567;
$string = sprintf "%.2f%%", $x * 100;
>Regards,
>
>Vic
--
--
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693
[EMAIL PROTECTED]