Fifth Script: Glitch

colomon on 2008-12-29T03:53:58

Skipping the fourth script, since the proper Perl-y way to do it is just call "cal", and the longer way really wants some sort of CPAN module to do it properly.

With the fifth script, I may have hit a glitch, either in Raduko or in my understanding of Perl 6.

my $wordfile = "wordlist.txt";

my @words = do
{
    my $words = open($wordfile) // die "Unable to open $wordfile: $!\n";
    =$words;
}

for (@*ARGS) -> $password
{
    say $password;
}
fails with
Statement not terminated properly at line 9, near "-> $passwo"

current instr.: 'parrot;PGE;Util;die' pc 129 (runtime/parrot/library/PGE/Util.pir:83)
called from Sub 'parrot;Perl6;Grammar;eat_terminator' pc 28665 (src/gen_grammar.pir:3378)
called from Sub 'parrot;Perl6;Grammar;statementlist' pc 27321 (src/gen_grammar.pir:2845)
called from Sub 'parrot;Perl6;Grammar;statement_block' pc 24757 (src/gen_grammar.pir:1838)
called from Sub 'parrot;Perl6;Grammar;TOP' pc 20647 (src/gen_grammar.pir:207)
called from Sub 'parrot;PCT;HLLCompiler;parse' pc 634 (src/PCT/HLLCompiler.pir:388)
called from Sub 'parrot;PCT;HLLCompiler;compile' pc 428 (src/PCT/HLLCompiler.pir:301)
called from Sub 'parrot;PCT;HLLCompiler;eval' pc 862 (src/PCT/HLLCompiler.pir:500)
called from Sub 'parrot;PCT;HLLCompiler;evalfiles' pc 1217 (src/PCT/HLLCompiler.pir:669)
called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1398 (src/PCT/HLLCompiler.pir:759)
called from Sub 'parrot;Perl6;Compiler;main' pc 18987 (perl6.pir:162)

Switching it to

my $wordfile = "wordlist.txt";

my @words = do
{
    my $words = open($wordfile) // die "Unable to open $wordfile: $!\n";
    =$words;
};

for (@*ARGS) -> $password
{
    say $password;
}
makes it work perfectly.

Should the semicolon always be there after the do construct? If so, why does it work if you insert a "say;" before the for statement?