in reply to Re: Re: Re: Re: dumb question
in thread post-increment and post-decrement behavior (was: dumb question)
Seriously, in your example $a is undef, which already has a meaning. If you look into perlsyn.pod, you'll find:
A variable holds the undefined value (C<undef>) until it has been assigned a defined value, which is anything other than C<undef>. When used as a number, C<undef> is treated as C<0>; when used as a string, it is treated the empty string, C<"">; and when used as a reference that isn't being assigned to, it is treated as an error. If you enable warnings, you'll be notified of an uninitialized value whenever you treat C<undef> as a string or a number. Well, usually.
Printing provides a string context, so $a must be treated as the empty string, and not as 0. That $a becomes a number after the print statement has completed is totally irrelevant in this discussion.
|
|---|