> >     $i = 20;
> >     my($x, $y, $z) = ($i++, +$i, $i++);
> 
> 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?

And the problem persists even if you make the negation effectively go away:

my $i = 20;
my ($x, $y, $z) = ($i++, -(-$i), $i++);
print "$x $y $z\n";

versus:

$i = 20;
my($x, $y, $z) = ($i++, $i, $i++);
print "$x $y $z\n";

I thought Perl had an expression optimizer that'd make that -(-...) go away, 
but I guess not..:o)

Also, the folks that have figured this all out already won't have a problem 
guessing what happens with this:

perl -e '$i = 20;
my($x, $y, $z) = (-(-$i), $i++, $i++);
print "$x $y $z\n";

And I think that in one of the first contributions here, where there was just 
the "+$i" term and folk observed that the '+' was apparently ignored, you 
trigger the odd anomaly by *forcing* Perl to have a proper expression there.  
that is, 

my $i = 20;
my($x, $y, $z) = ($i++, +$i, $i++);
print "$x $y $z\n";

versus

my $i = 20;
my($x, $y, $z) = ($i++, 0+$i, $i++);
print "$x $y $z\n";

  /Bernie\

-- 
Bernie Cosell                     Fantasy Farm Fibers
mailto:[EMAIL PROTECTED]     Pearisburg, VA
    -->  Too many people, too few sheep  <--          

Reply via email to