in reply to Dollars and regex cents
my @values = ('5.5', '9', '19.95'); foreach my $value (@values) { my $dollars = int $value; my $cents = $value - $dollars; my $converted_value = sprintf "\$$dollars.%02d", int ($cents * 100 + + .5); print "$converted_value\n"; } ---- $5.50 $9.00 $19.95
------
We are the carpenters and bricklayers of the Information Age.
Vote paco for President!
|
|---|