# New Ticket Created by "Carl Mäsak" # Please include the string: [perl #123309] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=123309 >
Quoth S06: As with module and class declarations, a sub declaration ending in semicolon is allowed at the outermost file scope if it is the first such declaration, in which case the rest of the file is the body: sub MAIN ($directory, :$verbose, *%other, *@filenames); for @filenames { ... } This form is allowed only for simple subs named C<MAIN> that are intended to be run from the command line. A C<proto> or C<multi> definition may not be written in semicolon form, nor may C<MAIN> subs within a module or class be written in semicolon form. (A C<MAIN> routine is allowed in a module or class, but is not usually invoked unless the file is run directly (see a above). This corresponds to the "unless caller" idiom of Perl 5.) In general, you may have only one semicolon-style declaration that controls the whole file. <masak> m: sub MAIN();say "OH HAI" <camelia> rakudo-moar 1e4fe4: OUTPUT«===SORRY!=== Error while compiling /tmp/A5naXHrUhHMissing blockat /tmp/A5naXHrUhH:1------> sub MAIN()⏏; [...] * masak submits NYI rakudobug <Mouq> masak: What's that supposed to do? <masak> Mouq: whole-file MAIN only sub. <Mouq> Ooo <masak> S06:3408 <synopsebot> Link: http://perlcabal.org/syn/S06.html#line_3408 <Mouq> Could be useful for one-liners too...