In Variables§
See primary documentation in context for Positional attributes
$/
can have positional attributes if the Regex had capture-groups in it, which are just formed with parentheses.
'abbbbbcdddddeffg' ~~ / a (b+) c (d+ef+) g /;say $/[0]; # OUTPUT: «「bbbbb」»say $/[1]; # OUTPUT: «「dddddeff」»
These can also be accessed by the shortcuts $0
, $1
, $2
, etc.
say $0; # OUTPUT: «「bbbbb」»say $1; # OUTPUT: «「dddddeff」»
To get all of the positional attributes, you can use $/.list
or @$/
. Before 6.d, you can also use the @()
shortcut (no spaces inside the parentheses).
say @$/.join; # OUTPUT: «bbbbbdddddeff»# 6.c language only:say @().join; # OUTPUT: «bbbbbdddddeff»
This magic behavior of @()
has been deprecated as of 6.d