SPUG: PerlWTF?
Andrew Sweger
andrew at sweger.net
Fri Apr 9 19:46:53 PDT 2010
On Fri, 9 Apr 2010, John W. Krahn wrote:
> They both don't do the same thing.
>
> [ snip ]
>
> $ perl -le'
> my $x = my $y = shift;
> $x = ( $x > 1 ) ? $x-- : 0;
> $y //= 0;
> $y-- if $y > 1;
> print "\$x = $x \$y = $y";
> ' -- -5
> $x = 0 $y = -5
>
> [ snip ]
>
> The correct expression would be:
>
> $x = ( $x > 1 ) ? $x - 1 : 0;
Ah, cool. I totally missed that.
The only minor change I would add is to precede it with $x //= 0;
Thanks.
--
Andrew B. Sweger -- The great thing about multitasking is that several
things can go wrong at once.
More information about the spug-list
mailing list