summaryrefslogtreecommitdiff
path: root/pod/perlop.pod
diff options
context:
space:
mode:
authorLukas Mai <l.mai@web.de>2016-01-31 00:40:36 +0100
committerLukas Mai <l.mai@web.de>2016-01-31 00:40:36 +0100
commit1b590b38db71fcbc56181e7ff704e9228c612e66 (patch)
tree1a97fe4788d20839627c07d86ac260ff90d7e3bc /pod/perlop.pod
parent52039d8f773b12b343fefe32df55d65fbde0424d (diff)
downloadperl-1b590b38db71fcbc56181e7ff704e9228c612e66.tar.gz
perlop: fix broken example by deleting it [perl #119667]
Diffstat (limited to 'pod/perlop.pod')
-rw-r--r--pod/perlop.pod18
1 files changed, 5 insertions, 13 deletions
diff --git a/pod/perlop.pod b/pod/perlop.pod
index 50ee6e0bfc..17d24bb4f7 100644
--- a/pod/perlop.pod
+++ b/pod/perlop.pod
@@ -775,19 +775,11 @@ might have. For example:
...
}
-or, if other non-required fields are allowed, use ARRAY ~~ HASH:
-
- use v5.10.1;
- sub make_dogtag {
- state $REQUIRED_FIELDS = { name=>1, rank=>1, serial_num=>1 };
-
- my ($class, $init_fields) = @_;
-
- die "Must supply (at least) name, rank, and serial number"
- unless [keys %{$init_fields}] ~~ $REQUIRED_FIELDS;
-
- ...
- }
+However, this only does what you mean if C<$init_fields> is indeed a hash
+reference. The condition C<$init_fields ~~ $REQUIRED_FIELDS> also allows the
+strings C<"name">, C<"rank">, C<"serial_num"> as well as any array reference
+that contains C<"name"> or C<"rank"> or C<"serial_num"> anywhere to pass
+through.
The smartmatch operator is most often used as the implicit operator of a
C<when> clause. See the section on "Switch Statements" in L<perlsyn>.