$# applies only to print itself doing the conversion. Interpolating the variable into a string doesn't bring it into play.
Exactly! Which is why this line works:
print "\n"," $amount ","-", $taxes," = ", $amount-$taxes;
Also note that $# is deprecated...
Which JamesNC would have known if he had enabled warnings.
... and it's better to explicitly run through sprintf than depend on it.
Is there a way to tell sprintf to add a dollar sign? Or do you have to explicitly append it? Like:
my $net = '$'.sprintf("%.2f", $amount - $taxes);
In reply to Re: Re: Odd behavior of $#
by Mr. Muskrat
in thread Odd behavior of $#
by JamesNC
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |