routine { }

Documentation for routine { }, assembled from the following types:

language documentation Operators

From Operators

(Operators) term { }

Block or Hash constructor.

If the content looks like a list of pairs and does not use $_ or other placeholder parameters, the constructor returns an itemized Hash.

Otherwise it constructs a Block.

Note that this construct does not re-parse the contents; rather, the contents are always parsed as a statement list (i.e. like a block), and if the later analysis shows that it needs to be interpreted as a hash, the block is executed and coerced to Hash.

language documentation Operators

From Operators

(Operators) postcircumfix { }

sub postcircumfix:<{ }>(%container**@key,
                        :$k:$v:$kv:$p:$exists:$delete)

Universal interface for associative access to zero or more elements of a %container, a.k.a. "hash indexing operator".

my %color = kiwi => "green"banana => "yellow"cherry => "red";
say %color{"banana"};                 # OUTPUT: «yellow␤» 
say %color{"cherry""kiwi"}.perl;    # OUTPUT: «("red", "green")␤» 
say %color{"strawberry"}:exists;      # OUTPUT: «False␤» 
 
%color{"banana""lime"} = "yellowish""green";
%color{"cherry"}:delete;
say %color;             # OUTPUT: «banana => yellowish, kiwi => green, lime => green␤» 

See postcircumfix < > and postcircumfix « » for convenient shortcuts, and Subscripts for a more detailed explanation of this operator's behavior, and how to implement support for it in custom types.