John Williams <[EMAIL PROTECTED]> writes:

>   $b = 'a';
>   my $b ='b' , print "$b\n";
>   print "$b\n";
>
> Which seems to show that the "my $b" doesn't actually come into
> scope until the end of the statement in which it is defined.

The comma operator doesn't guarantee order of operation because it's
building (or not bothering to build, in this case) a list.  I wouldn't
have been terribly surprised if the expression before the comma were
optimized out entirely, since the comma operator is in void context,
which is theoretically a form of scalar context in Perl5 IIRC.

People who think in terms of "statements" often get mixed up when they
put complex expressions in void context, expecting them to be treated
as statements.  print(2+3)*7; is another example.  Perl doesn't have
"statements" in the same sense that Pascal does.  It has expressions.

-- 
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,"[EMAIL PROTECTED]/ --";$\=$ ;-> ();print$/

Reply via email to