This is a method call:
("foo").first: /foo/
It's the same as if you had written:
("foo").first( /foo/ )
Or just:
"foo".first( /foo/ )
(Note that I used : at the end of the three above descriptions in English. That's where the idea to use : to mean that whatever following it is part of the same expression comes from.)
In this case it doesn't make a whole lot of sense to use first. Instead I would use ~~.
"foo" ~~ /foo/ andthen say "$_ bar";
first is used to find the first item in a list that matches some description. If you use it on a single item it will either return the item, or return Nil. It always returns one value, and Nil is the most sensible single undefined value in this case.
The reason it says it's expecting a colon pair is that is the only use of : that could be valid in that location. Honestly I halfway expected it to complain that it was an invalid label.
firstroutine (under List), it appears it’s a function that takes a lost and a reflex and returns the first match, ie it’s a function with the concept of matching built in, taking (effectively) two parameters. Your second example, the one that’s failing, has no function or operator which applies a match. Maybe you want~~or something (though this won’t do the same thing, ie trim results down to the first match).firstcommand seems very similar to Raku'sgrep. Do you see similar issues/problems in syntax?.first(...)is the same as.grep(...).head