From 1b590b38db71fcbc56181e7ff704e9228c612e66 Mon Sep 17 00:00:00 2001 From: Lukas Mai Date: Sun, 31 Jan 2016 00:40:36 +0100 Subject: perlop: fix broken example by deleting it [perl #119667] --- pod/perlop.pod | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'pod/perlop.pod') 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 clause. See the section on "Switch Statements" in L. -- cgit v1.2.1