- or download this
$m = 20; print ++$m + $m++;
- or download this
$m = 20; print noop(++$m) + $m++;
sub noop{ return shift }
- or download this
# This is an attempt at emulating ++$m with preInc($m)
sub preInc {
...
my $m = 20;
print preInc($m) + $postInc($m); # This prints 42.
# The final value is $m is 22.
- or download this
my $m=20;
print ++$m + $m++; # This prints 43 !
# The final value is $m is still 22.
- or download this
# Print values and addresses of passed argument and $m.
sub look {
...
my $m = 20;
my $p = look(++$m) + look($m++);
print $p;
- or download this
sub noop { # do nothing
return shift;
}
my $m=20; print noop(++$m) + $m++; # This prints 42 !
- or download this
==== increment weirdness: ++$m + $m++ ==========
m = 20 at 0x80ab23c
...
*** add : 22 at 0x804c120 + 21 at 0x80ab23c = 43 at 0x80ab11c
m is 22 at 0x804c120
p = 43 at 0x80ab11c