From: Vincent Pit Date: Tue, 10 Nov 2009 22:50:06 +0000 (+0100) Subject: Clarify and complete documentation for in-place reverse X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=437d4214522421889ca7657c5c9e7dc2f6d1ef7b;p=p5sagit%2Fp5-mst-13.2.git Clarify and complete documentation for in-place reverse --- diff --git a/pod/perl5112delta.pod b/pod/perl5112delta.pod index 0fed626..82412b2 100644 --- a/pod/perl5112delta.pod +++ b/pod/perl5112delta.pod @@ -166,8 +166,10 @@ Any changes to F should go in L. =item * -Reversing an array in-place in void context is now several orders of magnitude faster than it used to be. -It will also preserve non-existent elements whenever possible, i.e. for non magical arrays or tied arrays with C and C methods. +Reversing an array to itself (as in C<@a = reverse @a>) in void context now +happens in-place and is several orders of magnitude faster than it used to be. +It will also preserve non-existent elements whenever possible, i.e. for non +magical arrays or tied arrays with C and C methods. =back diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 862e0ba..53c318f 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -4782,6 +4782,10 @@ Used without arguments in scalar context, reverse() reverses C<$_>. print reverse; # No output, list context print scalar reverse; # Hello, world +Note that reversing an array to itself (as in C<@a = reverse @a>) will +preserve non-existent elements whenever possible, i.e. for non magical +arrays or tied arrays with C and C methods. + 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