in reply to letters++, bug or trick?

This is not a bug nor a trick neither, the ++ operator works on strings stored in scalar variables as long as they have never been used in a numeric context, once these variables are used in a numeric context a re-initialization of the variable's value into a number takes place..
#!/usr/local/bin/perl $c = "c"; print ++$c," from c\n"; print ++$c," from d\n"; #apply the same in numeric context $c+=0; print $c, " from numeric operation\n"; print ++$c, " incremented after numeric assignment";
However, Perl would throw a warning when it reaches to "$c+=0;" telling you that a non-numeric argument is used in the addition operation if you have turned warnings on via "use warnings" which can save you from introducing a potentially hard-to-track bug otherwise...


Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.