in reply to Succinct switch statement

Altho the given-when thing is cool, it would be cooler if the given() could be left out.

It can. given just sets $_, and the outer while-loop does that already, so it's really redundant.

And, by the way, is there an even shorter way to do print "\n"; ?

say.

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: Succinct switch statement
by ikegami (Patriarch) on Oct 23, 2009 at 21:04 UTC
    No, it can't. You get error Can't use when() outside a topicalizer (5.10.1).
      I tested it with a for loop, which works. The difference seems to be that while doesn't limit the scope of $_ in any way.
Re^2: Succinct switch statement
by Anonymous Monk on Oct 23, 2009 at 21:18 UTC
    And say prints $_, doesn't it?
      And say prints $_, doesn't it?
      Do you see any mention of $_ in The Fine Manual? I don't. If you don't believe the documentation, you could always write your own code to answer your own question.
        No, but I see mention of "just like print". And print; prints $_, so it's a safe assumption that say does as well, only with an implicit \n.