diff options
author | smash <smash@cpan.org> | 2011-05-16 15:08:59 +0100 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-06-05 13:53:32 -0700 |
commit | b0a61ffaf80911551f4084d7cc96f473e88ee0fb (patch) | |
tree | 76c50bb475736f7bff88633b685c1233e5f4f511 | |
parent | 92997e40e7cbb0e75f78077a6a3266bc2fae9514 (diff) | |
download | perl-b0a61ffaf80911551f4084d7cc96f473e88ee0fb.tar.gz |
add given when to perfunc
(cherry picked from commit 15a348aa1f233f84aedc3c0a7bcc9d29fc6dc9e9)
-rw-r--r-- | pod/perlfunc.pod | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 0b593b9d52..1ff463824d 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -2411,6 +2411,29 @@ An example to test whether Nagle's algorithm is turned on on a socket: print "Nagle's algorithm is turned ", $nodelay ? "off\n" : "on\n"; +=item given EXPR BLOCK +X<given> + +=item given BLOCK + +C<given> is analogous to the C<switch> keyword in other languages. C<given> +and C<when> are used in Perl to implement C<switch>/C<case> like statements. +For example: + + given ($fruit) { + when (/apples?/) { + print "I like apples." + } + when (/oranges?/) { + print "I don't like oranges." + } + default { + print "I don't like anything" + } + } + +See L<perlsyn/"Switch statements"> for detailed information. + =item glob EXPR X<glob> X<wildcard> X<filename, expansion> X<expand> @@ -7869,6 +7892,29 @@ See L<perlvar> for details on setting C<%SIG> entries, and for more examples. See the Carp module for other kinds of warnings using its carp() and cluck() functions. +=item when EXPR BLOCK +X<when> + +=item when BLOCK + +C<when> is analogous to the C<case> keyword in other languages. C<given> +and C<when> are used in Perl to implement C<switch>/C<case> like statements. +For example: + + given ($fruit) { + when (/apples?/) { + print "I like apples." + } + when (/oranges?/) { + print "I don't like oranges." + } + default { + print "I don't like anything" + } + } + +See L<perlsyn/"Switch statements"> for detailed information. + =item write FILEHANDLE X<write> |