Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

colomon (8994)

colomon
  (email not shown publicly)

Journal of colomon (8994)

Sunday December 28, 2008
10:53 PM

Fifth Script: Glitch

[ #38173 ]
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?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.