Change 33840 by [EMAIL PROTECTED] on 2008/05/17 10:01:08
Subject: [perl #39187] [DOC-PATCH]: perldoc -f reverse: examples (was:
RE: Perlfunc needs to be made more clear regarding reverse in scalar context.)
From: "Bram via RT" <[EMAIL PROTECTED]>
Date: Fri, 16 May 2008 14:44:07 -0700
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/pod/perlfunc.pod#600 edit
Differences ...
==== //depot/perl/pod/perlfunc.pod#600 (text) ====
Index: perl/pod/perlfunc.pod
--- perl/pod/perlfunc.pod#599~33834~ 2008-05-16 05:17:03.000000000 -0700
+++ perl/pod/perlfunc.pod 2008-05-17 03:01:08.000000000 -0700
@@ -4718,13 +4718,16 @@
elements of LIST and returns a string value with all characters
in the opposite order.
- print reverse <>; # line tac, last line first
+ print join(", ", reverse "world", "Hello"); # Hello, world
- undef $/; # for efficiency of <>
- print scalar reverse <>; # character tac, last line tsrif
+ print scalar reverse "dlrow ,", "olleH"; # Hello, world
Used without arguments in scalar context, reverse() reverses C<$_>.
+ $_ = "dlrow ,olleH";
+ print reverse; # No output, list context
+ print scalar reverse; # Hello, world
+
This operator is also handy for inverting a hash, although there are some
caveats. If a value is duplicated in the original hash, only one of those
can be represented as a key in the inverted hash. Also, this has to
End of Patch.