You have two problems: (1) matches start from 0, not 1. (2) .* gobbles as much as possible (this is also true in Perl 5) so it matches to the ) at the end of (Sub|63218616). As in Perl 5, you add a ? to make it take the shortest match instead:
#!/usr/bin/perl6 my $x='sub Test () { #`(Sub|63218616) ... }'; $x ~~ m/sub (.*?) \(/; say "$x\n$0"; On Mon, Mar 13, 2017 at 10:46 PM, ToddAndMargo <toddandma...@zoho.com> wrote: > Hi All, > > > Just as soon as I think I understand it, a little > humility fall into my lap! > > <code> > #!/usr/bin/perl6 > my $x='sub Test () { #`(Sub|63218616) ... }'; > $x ~~ m/sub (.*) \(/; > say "$x\n$1"; > </code> > > $ WhoTest2.pl6 > Use of Nil in string context > in block <unit> at ./WhoTest2.pl6 line 4 > sub Test () { #`(Sub|63218616) ... } > > > This is what I want to do. "sub " will > always be repeated and have a space after it. > > " (" will always be repeated and have a space before > it. > > I want what occurs between "sub " and " (" > > What am I doing wrong? This time? > > > Many thanks, > -T > > > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Serious error. > All shortcuts have disappeared. > Screen. Mind. Both are blank. > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net