Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

SOLVED: Perl6, latest Rakudo bug or error on my part?

by Utilitarian (Vicar)
on Aug 07, 2010 at 13:48 UTC ( #853573=perlquestion: print w/ replies, xml ) Need Help??
Utilitarian has asked for the wisdom of the Perl Monks concerning the following question:

Like many monks here, I suspect, I've become used to Perl-5 and have to an extent disbelieved in the advent of Perl-6. However, due to the poll and constant references to Rakudo in some monks posts, I am spending this weekend playing with it rather than pottering in the garden.

I got the latest from github built and installed and I'm working my way through "Using Perl 6" at the moment.

So may I extend a hearty thanks and congratulations to all involved, and request they undo the terrible damage they have caused in my household by popping over and doing the lawns ;)

Now, on to the question, The following code gives me the error stated, is there something obvious I'm not getting WRT blocks in Perl 6?

#! /usr/local/bin/perl6 #vim: filetype=perl6 use v6; my $var="Does this work"; for $var.split(' ') -> $word{ if $word eq 'work'{ say "That worked we reached the end of the string";
        }else{
say "Getting there..."; } }
Gives the error:
===SORRY!=== Missing block at line 8, near "else{\n\t\tsa"
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

Comment on SOLVED: Perl6, latest Rakudo bug or error on my part?
Select or Download Code
Re: Perl6, latest Rakudo bug or error on my part?
by fod (Friar) on Aug 07, 2010 at 16:00 UTC
    Hi Utilitarian I've been playing around with Rakudo a little too. I don't know the why of it but it seems that the existence (or not) of a space between a loop or conditional statement and the opening curly-brace is significant. For instance this works as intended:
    #!/usr/bin/perl6 use v6; my $var="Does this work"; say $var; for $var.split(' ') -> $word { if $word eq 'work' { say "end of string"; }else {say "getting there..."; } }
Re: Perl6, latest Rakudo bug or error on my part?
by Utilitarian (Vicar) on Aug 07, 2010 at 16:08 UTC
    Thanks fod

    I got it and came here to post when I saw your response, so space is meaningful, how very pythonesque

    print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
      how very pythonesque

      Py tho nisn'ttheonl yla nguageinwhichtheappropriate useofwhitespacecontribu testoparsability;t rywritingadowhilel oopinPerl5withoutaspa cesom e t i me.

        Valid point, entertainingly made, and I am entirely sincere in my gratitude for the work you and others have put into Rakudo. It just seems strange, coming from Perl 5. that }else{ isn't parseable as I would expect.

        I spent a very educational weekend however and may even attempt, in my limited way, to contribute to the project.

        print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
Re: SOLVED: Perl6, latest Rakudo bug or error on my part?
by moritz (Cardinal) on Aug 07, 2010 at 23:15 UTC
    See Re: Perl6, modifying @*INC for an explanation why spaces before bracketing characters are important, in general.
    Perl 6 - links to (nearly) everything that is Perl 6.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://853573]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2015-07-02 05:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (28 votes), past polls