On Sun, May 18, 2003 at 03:18:04AM +0200, Slaven Rezic wrote: > > print "increasing a to 1\n" if ($a++); > > print "increasing a to 2\n" if ($a++); > > ---------------------------------------------------------------------- > > 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. To clarify, post-increment means the value is checked and *then* its incremented. Like: if( $a ) { print "increasing a to 1\n"; } $a += 1; useful for things like: do_something_once unless $Done_Something++; instead of: unless( $Done_Something ) { do_something_once; $Done_Something += 1; } To make your example work the way you expected, use ++$a (pre-increment). -- Keep your stick on the ice. -- Red GreenThread Previous