in reply to Re: Odd behavior of $#
in thread Odd behavior of $#
$# 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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (3): Odd behavior of $#
by VSarkiss (Monsignor) on Feb 19, 2003 at 19:52 UTC | |
|
Re^3: Odd behavior of $#
by diotalevi (Canon) on Feb 19, 2003 at 19:52 UTC | |
by Nkuvu (Priest) on Feb 19, 2003 at 20:37 UTC | |
|
Re: Re: Re: Odd behavior of $#
by Fletch (Bishop) on Feb 19, 2003 at 20:36 UTC |