On 6/12/07, Angerstein <[EMAIL PROTECTED]> wrote:
Perl does $x="0001"; $x++; print $x; Output: 0002 BUT $x="0002"; $x--; print $x; Output: 1 Why and how can I avoid that. (yes, i know about printf)
So use it ;-) Read the section "Auto-increment and Auto-decrement" in " perldoc perlop " which ends with the phrase The auto-decrement operator is not magical. Unlike ++, which keeps the string-ish nature of the variable contents, the -- operator turns the string into a number and simply does a numerical decrement with it. So if you need this four digit format and a decrement, you'll have to use printf (or sprintf). Cheers, Adriano Ferreira.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/