1) How to make without $/
make ... is just a shortcut to $/.make(...) .
If you want to influence a different Match object than the one stored in $/ , you need to use the form of the method directly, i.e. in your case $x.make($result) .
2) When and why $/ is read-only
By default, $/ bound to the container of a normal element (for example, a variable declared with my ), i.e. not just for reading. Therefore, there should be no problem using the .match method several times in a subroutine.
This is only when you explicitly declare $/ as a parameter in the signature routine, that $/ will be bound directly to the Match object passed to this procedure (not wrapped in an element container), and thus will be read-only inside the routine - due to how normal signature binding works.
You can use the is copy flag to override the standard binding of the parameter as read-only, and force $/ is the container of the variable element inside the procedure:
method foo ($/ is copy) { ... }
Thus, using .match inside the routine will work and will store the new Match object in $/ . But then you will no longer have access to the original Match object passed to the procedure, and therefore, it will not be able to affect it with make . So for the action method that .match should use, using the name of the custom parameter, as you did, is the way to go.
source share