in reply to letters++, bug or trick?
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...#!/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";
|
|---|