in reply to Increment avoids warning unexpectedly
The pre-increment and post-increment operators are designed to work on strings too. Witness the following:
my $string = "abc"; print ++$string, "\n";
If my calculations are correct, you should see "abd".
So the point is that if you give ++ a string that it can figure out, it will increment it. Thus, non-numeric strings are legal arguments for ++. Now, in your case, you gave the increment operator a string that it couldn't sensibly increment in its non-numeric form, so the ++ operator dropped into numeric form, and incremented 0 to 1. No warning because non-numeric strings are legal in this case.
To read more about the ++ operator's "magic", see perlop.
Dave
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Increment avoids warning unexpectedly
by ikegami (Patriarch) on Jun 07, 2006 at 17:23 UTC | |
Re^2: Increment avoids warning unexpectedly
by jpeg (Chaplain) on Jun 07, 2006 at 16:45 UTC | |
Re^2: Increment avoids warning unexpectedly
by Hue-Bond (Priest) on Jun 23, 2006 at 22:00 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |
In Section
Seekers of Perl Wisdom