It's not only in -e. I just used that for my example. A file with a unit sub MAIN exhibits the same issue.
On Mon, Mar 28, 2016, 17:39 Elizabeth Mattijsen via RT < perl6-bugs-follo...@perl.org> wrote: > Perhaps we should disallow “unit” with -e? > > > On 28 Mar 2016, at 20:18, Trey Ethan Harris <t...@cpan.org> wrote: > > > > No, see S06-routines.pod: > > > > As with module and class declarations, a sub declared > > with the C<unit> declarator (and 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: > > > > unit 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. > > > > > > On Sat, Mar 26, 2016 at 7:02 AM Elizabeth Mattijsen via RT < > perl6-bugs-follo...@perl.org> wrote: > > unit sub ??? > > > > I thought that unit was only supposed to be followed by a package like > declaration?? > > > > > > > On 26 Mar 2016, at 02:10, Trey Harris (via RT) < > perl6-bugs-follo...@perl.org> wrote: > > > > > > # New Ticket Created by Trey Harris > > > # Please include the string: [perl #127785] > > > # in the subject line of all future correspondence about this issue. > > > # <URL: https://rt.perl.org/Ticket/Display.html?id=127785 > > > > > > > > > > Example: > > > > > > % perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 4 > > > big > > > % perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 0 > > > Usage: > > > -e '...' <x> > > > % perl6 -e 'unit sub MAIN ($x where { $^x > 1 } ); say "big"' 4 > > > ===SORRY!=== > > > Expression needs parens to avoid gobbling block > > > at -e:1 > > > ------> unit sub MAIN ($x where { $^x > 1 }⏏ ); say "big" > > > Missing block (apparently claimed by expression) > > > at -e:1 > > > ------> unit sub MAIN ($x where { $^x > 1 } );⏏ say "big" > > > > > > > > > >