Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Replaying Santa Claus Golf Apocalypse with Pugs/Perl6

by rg0now (Chaplain)
on Mar 12, 2005 at 19:42 UTC ( #438980=note: print w/replies, xml ) Need Help??

in reply to Replaying Santa Claus Golf Apocalypse with Pugs/Perl6

After updating to the most current Pugs and incorporating all the ideas above, here is my final strike on the Santa Claus Perl6/Pugs Golf Apocalypse:
--- head.p6 --------------------------------------------- print*(=open@ARGS[0])[0..9] --- tail.p6 --------------------------------------------- my@l= =open@ARGS[0]; print@l[(@l>9??@l-10::0)...] --- rev.p6 --------------------------------------------- print reverse=open@ARGS[0] --- mid.p6 --------------------------------------------- my@l= =open@ARGS[0]; print@l[int((@l-1)/2)] --- wc.p6 --------------------------------------------- say*(split"",int(7e10+ +*(=open@ARGS[0])))[1..11]
It is all but nice but is is actually only 203 strokes...:-)


Replies are listed 'Best First'.
Re^2: Replaying Santa Claus Golf Apocalypse with Pugs/Perl6
by audreyt (Hermit) on Mar 12, 2005 at 20:15 UTC
    Hey, why =open@ARGV[0] instead of =<> again? That will save 10 strokes per hole, bringing it to a more respectable 153...
      This is because we are ran by
      my $cmd = "pugs $scr $intmp";
      which means that we are getting the name of the file to be read as the first command line argument. But, based on my (granted, limited) understanding, =<> would read from the standard input. Am I completely missing something here again?


        =<> is supposed work the same as magical <> in Perl 5. To explicitly read from standard input would require =$*IN instead.
Re^2: Replaying Santa Claus Golf Apocalypse with Pugs/Perl6
by pdcawley (Hermit) on Mar 29, 2005 at 07:47 UTC
    Can open take a block yet?
    or is open ... {...} a figment of my imagination?
      Quite a strange syntax, I think. And apparently, Pugs thinks so too, because it croaks badly when I try to run your version.

      Even though, the fact that neither Pugs nor me seem to recognize this syntax, this does not mean to any extent that it is illegal. If you can recall where you met it, I can definitely make a todo_test out of it for autrijus to implement...


        It's a rubyish thing: Open this and then call the block for every line of the resulting file handle, closing the file at the end. I'd not be surprised if it's a hopeful figment of my imagination.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://438980]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2018-06-20 23:13 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.