Roman Hlynovskiy (via RT) <perlbug-followup@perl.org> writes: > # New Ticket Created by Roman Hlynovskiy > # Please include the string: [perl #22229] > # in the subject line of all future correspondence about this issue. > # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=22229 > > > > Hello , perlbug > > i think i found some kind of bug. below you'll find short description > and this is the sample, showing it... > > ---------------------------------------------------------------------- > [root@lnx01][capturer]#> cat gluck.pl > #!/usr/bin/perl > > $a = 0; > $b = 0; > > print "increasing a to 1\n" if ($a++); > print "increasing a to 2\n" if ($a++); > > print "increasing b to 1\n" if ($b+=1); > print "increasing b to 2\n" if ($b+=1); > > print "increasing c to 1\n" if ($c++); > print "increasing c to 2\n" if ($c++); > > print "increasing d to 1\n" if ($d+=1); > print "increasing d to 2\n" if ($d+=1); > [root@lnx01][capturer]#> ./gluck.pl > increasing a to 2 > increasing b to 1 > increasing b to 2 > increasing c to 2 > increasing d to 1 > increasing d to 2 > ---------------------------------------------------------------------- > i.e. if trying to increase zero-valued (or undefined) scalar the > result is always false if using '++' operator. > below is perl -V from my system. i also tried it on 5.005_03 and it > worked the same manner. This works as expected, because $var++ is the post increment operator. If you want pre increment, then use ++$var instead. Regards, Slaven -- Slaven Rezic - slaven@rezic.de tktimex - project time manager http://sourceforge.net/projects/ptktools/Thread Previous | Thread Next