Literals & quoting
Pairs
FullA single key-to-value association — the building block of hashes and named args.
A Pair links one key to one value, written key => value. Pairs are the elements of a hash, the form of named arguments, and a value in their own right.
The fat-arrow form #
my $p = a => 1; say $p; say $p.key; say $p.value;
Output
a => 1
a
1Colon-pair forms #
:key(value) is the same Pair; :key alone means key => True, and :key<word> uses a quoted-word value. These are exactly the forms used for named arguments.
say (:x(5)); say (:done); my $q = :name<Ada>; say $q;
Output
x => 5
done => True
name => AdaNotes #
:$varis shorthand forvar => $var— the pattern behind named arguments.- A list of Pairs is what initialises a hash:
my %h = a => 1, b => 2. :!keyiskey => False, the negated colon-pair — common for turning a flag off.