> You may be in luck, and it may do precisely what you want, but by the
> time you made sure it does, you've already wasted far too much time on
> it. Here is an example that mosty likely *not* do what you want:
>
> $i = 20;
> my($x, $y, $z) = ($i++, $i, $i++);
This is a great example, as only your warning hinted that it did
something other than:
x = 20
y = 21
z = 21
i = 22
> As to what the next does,
>
> $i = 20;
> my($x, $y, $z) = ($i++, +$i, $i++);
>
> your guess is a good as any.
You are trying too hard to catch us out, the "+" just enforces scalar
context so "$i" and "+$i" are identical - and thus we can easily
conclude it is the same as the last example.
Here is a good addition to Bart's examples:
my $i = 20;
my ($x, $y, $z) = ($i++, -$i, $i++);
print "$x $y $z\n";
Understanding the other examples... can you guess what does it prints?
Now, it appears that perl's evaluation order is accident rather than
design - so you SHOULD NOT rely on it. Avoid causing side-effects on
variables you use more than once... including the multiple use of shift
in assignment.
Jonathan Paton
=====
s''! v+v+v+v+ J r e P h+h+h+h+ !s`\x21`~`g,s`^ . | ~.*``mg,$v=q.
P ! v-v-v-v- u l r e r h-h-h- !12.,@.=m`.`g;do{$.=$2.$1,$.=~s`h
E ! v+v+v+ s k e h+h+ !`2`x,$.=~s`v`31`,print$.[$v+=$.]
R ! v-v- t H a c h h- !}while/([hv])([+-])/g;print"\xA"
L ! A n o t !';$..=$1while/([^!]*)$/mg;eval$.
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com