Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
improve Hash, provide link to subscripts
  • Loading branch information
gfldex committed Jun 15, 2016
1 parent 5fe50f7 commit 0feafb2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions doc/Type/Hash.pod
Expand Up @@ -15,10 +15,18 @@ Hashes are usually stored in variables with the percent C<%> sigil.
Hash elements are accessed by key via the C<{ }> postcircumfix operator:
my $home = %*ENV{'HOME'};
For literal string keys without whitespace, C< < > > can be used instead:
my $home = %*ENV<HOME>;
dd %*ENV{'HOME', 'PATH'};
# OUTPUT«("/home/camelia", "/usr/bin:/sbin:/bin")␤»
The general L<Subscript|/language/subscripts> rules apply providing shortcuts
for lists of literal strings, with and without interpolation.
my %h = oranges => 'round', bananas => 'bendy';
dd %h<oranges bananas>;
# OUTPUT«("round", "bendy")␤»
my $fruit = 'bananas';
dd %h«oranges $fruit»
OUTPUT«("round", "bendy")␤»
You can add new pairs simply by assigning to an unused key:
Expand Down

0 comments on commit 0feafb2

Please sign in to comment.