in reply to pre v.s. post (increment/decrement)
Relevant snippet from perlop:
"++" and "--" work as in C. That is, if placed before a variable, they increment or decrement the variable before returning the value, and if placed after, increment or decrement the variable after returning the value.
The only difference is in what value is returned. Maybe the following code will demonstrate the difference more clearly:
$a = 1; print ++$a, ":", $a, "\n"; $a = 1; print $a++, ":", $a, "\n";
Update: yikes. 2 answers were posted in the time it took me to compose mine. I had a feeling this would happen with a question like this... :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: pre v.s. post (increment/decrement)
by Abigail-II (Bishop) on Jul 11, 2003 at 00:01 UTC |