routine |

Documentation for routine | assembled from the following types:

language documentation Operators

From Operators

(Operators) prefix |

Flattens objects of type Capture, Pair, List, Map and Hash into an argument list.

sub slurpee|args ){
    say args.perl
};
slurpee( <a b c d>{ => 3 }'e' => 'f' => 33 )
# OUTPUT: «\(("a", "b", "c", "d"), {:e(3)}, :e(:f(33)))␤» 

Please see the Signature page, specially the section on Captures for more information on the subject.

Outside of argument lists, it returns a Slip, which makes it flatten into the outer list. Inside argument list Positionals are turned into positional arguments and Associatives are turned into named arguments.

language documentation Operators

From Operators

(Operators) infix |

multi sub infix:<|>($a$b --> Junction:Dis assoc<list>

Creates an any Junction from its arguments.

my $three-letters = /<[a b c]>/ | /<[i j k]>/ | /<[x y z]>/;
say $three-letters.perl# OUTPUT: «any(/<[a b c]>/, /<[i j k]>/, /<[x y z]>/)␤» 
say 'b' ~~ $three-letters# OUTPUT: «True␤» 

This first creates an any Junction of three regular expressions (every one of them matching any of 3 letters), and then uses smartmatching to check whether the letter b matches any of them, resulting in a positive match. See also Junction for more details.