Patrick (>): > If both pugs and rakudo agree on an error, I'd bet that the > problem is in the program and not the compiler(s). :-) > > In this case, the problem is the lack of a space before the > angle bracket in the loop statement: > > loop (my $i=0;$i<2;$i++) { > ... > if ($n > 2) { say "$n is bigger than 2";} > > Perl 6 sees the angle bracket following the "$i" as being a > subscript using the <...> notation, which ends at the angle > bracket in the "if" statement. It then complains about not > understanding the "2" that follows the closing angle bracket. > > S03:2793 notes this explicitly: > > Note: any operator beginning with C<< < >> must have whitespace > in front of it, or it will be interpreted as a hash subscript instead. > > So, add a whitespace character in front of the opening angle bracket, > and all works (at least in rakudo): > > $ cat x > #!/usr/local/bin/pugs -w > > loop (my $i = 0; $i < 2; $i++) { > say $i; > } > > my $n = 7; > if ($n > 2) { say "$n is bigger than 2";} > > $ ./parrot perl6.pbc x > 0 > 1 > 7 is bigger than 2
There's a related problem when using empty parens after the 'loop' keyword, however: $ cat test.p6 loop () { } my $n $ ./perl6 test.p6 Statement not terminated properly at line 1, near "{\n}\nmy $n\n" [...] That can't be related to the <...> notation. Are empty parens allowed here? // Carl