In Variables§

See primary documentation in context for The $/ variable

$/ is the match variable. A fresh one is created in every routine. It is set to the result of the last Regex match and so usually contains objects of type Match.

'abc 12' ~~ /\w+/;  # sets $/ to a Match object 
say $/.Str;         # OUTPUT: «abc␤»

The Grammar.parse method also sets the caller's $/ to the resulting Match object. For the following code:

use XML::Grammar# zef install XML 
XML::Grammar.parse("<p>some text</p>");
say $/;
 
# OUTPUT: «「<p>some text</p>」 
#           root => 「<p>some text</p>」 
#            name => 「p」 
#            child => 「some text」 
#             text => 「some text」 
#             textnode => 「some text」 
#           element => 「<p>some text</p>」 
#            name => 「p」 
#            child => 「some text」 
#             text => 「some text」 
#             textnode => 「some text」␤» 

Prior to the 6.d version, you could use $() shortcut to get the ast value from $/ Match if that value is truthy, or the stringification of the Match object otherwise.

'test' ~~ /.../;
# 6.c language only: 
say $(); # OUTPUT: «tes␤»; 
$/.make: 'McTesty';
say $(); # OUTPUT: «McTesty␤»;

This (non-)feature has been deprecated as of version 6.d.