in reply to Odd behavior of $#

I think you're coming up against a bit of perl DWIMery, that it decides a string "looks like a number" if it has only whitespace around the number. You can work around it by not doing that (eg by having "\n$amount -"), but you are best off just using printf and avoiding the (deprecated) $# variable:

printf "\n%s - %2f = %.2f", $amount, $taxes, $amount - $taxes;

Hugo

Replies are listed 'Best First'.
Re: Re: Odd behavior of $#
by JamesNC (Chaplain) on Feb 19, 2003 at 19:34 UTC
    Thanks all.. I knew how to do this using sprintf and printf, I just wanted to know why it acted wacky. Perhaps this is why it is deprecated??