develooper Front page | perl.perl5.porters | Postings from June 2008

Re: print: wrong order of evaluation

Thread Previous | Thread Next
From:
Dr.Ruud
Date:
June 25, 2008 00:58
Subject:
Re: print: wrong order of evaluation
Message ID:
20080625075753.24096.qmail@lists.develooper.com
Reini Urban schreef:

> I wonder if this strange behaviour is known:
> 
> $ perl -e'my $i = 1;
> my $foo = sub {
>   $i = shift if @_
> };
> print $i,&$foo(3),$i;'
> 333
> 
> $ perl -e'my $i = 1;
> my $foo = sub {
>   $i = shift if @_
> };
> print $i; print &$foo(3),$i;'
> 133
> 
> The first seems very wrong to me.

I don't consider it wrong. Shorter:

$ perl -le'my $i = 1; print $i, $i = 3'
33

-- 
Affijn, Ruud

"Gewoon is een tijger."

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About