In Regexes§

See primary documentation in context for Modified quantifier: %, %%

To more easily match things like comma separated values, you can tack on a % modifier to any of the above quantifiers to specify a separator that must occur between each of the matches. For example, a+ % ',' will match a or a,a or a,a,a, etc.

%% is like %, with the difference that it can optionally match trailing delimiters as well. This means that besides a and a,a, it can also match a, and a,a,.

The quantifier interacts with % and controls the number of overall repetitions that can match successfully, so a* % ',' also matches the empty string. If you want match words delimited by commas, you might need to nest an ordinary and a modified quantifier:

say so 'abc,def' ~~ / ^ [\w+** 1 % ',' $ /;  # OUTPUT: «False␤» 
say so 'abc,def' ~~ / ^ [\w+** 2 % ',' $ /;  # OUTPUT: «True␤» 

In Variables§

See primary documentation in context for The % variable

In addition, there's an Associative anonymous state variable %.

sub foo($x{
    say (%).push($x => $x);
}
 
foo($_for ^3;
 
# OUTPUT: «{0 => 0} 
#          {0 => 0, 1 => 1} 
#          {0 => 0, 1 => 1, 2 => 2}␤»

The same caveat about disambiguation applies. As you may expect, indexed access is also possible (with copying to make it useful).

sub foo($x{
    my $v = %;
    $v{$x} = $x;
    say $v;
}
 
foo($_for ^3;
 
# OUTPUT: «{0 => 0} 
#          {0 => 0, 1 => 1} 
#          {0 => 0, 1 => 1, 2 => 2}␤»

As with the other anonymous state variables, each mention of % within a given scope will effectively introduce a separate variable.