I think i see the problem from readin the other posts. You appear to be printing to a webpage which is not recognizing the consecutive spaces (or, atleast, not displaying them). Just for the sake of sprintf(), i should mention that , if the number before the . in the sprintf() format is positive, the number is right justified, and a negative number to the left of the . left justifies the number. so ...
#!/usr/bin/perl -w
use strict; # every job should
my $number = 222.42;
printf("A: \$%10.2f\n",$number);
printf("B: \$%-10.2f\n",$number);
... would print ...
%shell > perl test.pl
A: $ 222.42
B: $222.42
If HTML : There are quite a few ways to do it, and i have even been known to use something like the following before printing. But, i am not a CGI programmer, so i am sure there are better ways.
sub html_space {
my $Rstring = shift;
$$Rstring =~ s/ / /g;
}
... and a test program ...
#!/usr/bin/perl -w
use strict; # every job should
my $number = 222.42;
$number = sprintf("\$%10.2f\n",$number);
&html_space(\$number);
print "A: $number\n";
sub html_space {
my $Rstring = shift;
$$Rstring =~ s/ / /g;
}
can't sleep clawns will eat me
-- MZSanford
|