That particular example is flawed, because the try expression is turned
into a try statement because the } stands alone on its line.

But if you eliminate a couple newlines between } and for, then your
question makes sense (but the code is not well structured, but hey, maybe
you take out all the newlines for a one-liner...).

The answer in that case is probably a syntax error, and to avoid it, you
put a ; between the } and the for.


Piers Cawley wrote:

> Okay boys and girls, what does this print:
>
> my @aaa = qw/1 2 3/;
> my @bbb = @aaa;
>
> try {
>     print "$_\n";
> }
>
> for @aaa; @bbb -> my $a; my $b {
>     print "$a:$b";
> }
>
> I'm guessing one of:
> 1:1
> 2:2
> 3:3
>
> or a syntax error, complaining about something near
> C<@bbb -> my $a ; my $b {>
>
> In other words, how does the parser distinguish between postfix for
> followed by a semicolon, and the new semicolon enhanced 'normal' for?
>
> --
> Piers
>
>    "It is a truth universally acknowledged that a language in
>     possession of a rich syntax must be in need of a rewrite."
>          -- Jane Austen?

--
Glenn
=====
Due to the current economic situation, the light at the
end of the tunnel will be turned off until further notice.


Reply via email to