I can write something like this (elem here is an XML::Element but it doesn't really matter):
for $elem.nodes { when XML::Element { ... } when XML::Text { ... } ... default { note qq{Ignoring unknown XML node "$_".} } } which looks nice, but doesn't give me a readable name for $_ inside the code using it, which is why I'd prefer to write this:
for $elem.nodes -> $child { when XML::Element { ... } when XML::Text { ... } ... default { note qq{Ignoring unknown XML node "$child".} } } but this doesn't work because now $_ isn't set, and so I actually need to write
for $elem.nodes -> $child { given $child { when XML::Element { ... } when XML::Text { ... } ... default { note qq{Ignoring unknown XML node "$child".} } } } which is a bit redundant and adds an extra level of indentation.
It's definitely not the end of the world, but am I missing some simple way to have both a readable variable name and avoid given?