develooper Front page | perl.perl5.porters | Postings from April 2003

Re: [perl #7213] [PATCH] Updating example in perldata

Thread Previous | Thread Next
From:
Casey West
Date:
April 24, 2003 18:23
Subject:
Re: [perl #7213] [PATCH] Updating example in perldata
Message ID:
20030425012722.GN34510@geeknest.com
It was Friday, April 25, 2003 when Tony Cook took the soap box, saying:
: On Thu, Apr 24, 2003 at 08:42:32PM -0400, Casey West wrote:
: > http://rt.perl.org/rt2/Ticket/Display.html?id=7213
: > --- perl-current.orig/pod/perldata.pod  Mon Mar  4 04:18:27 2002
: > +++ perl-current/pod/perldata.pod       Thu Apr 24 20:35:56 2003
: > @@ -644,7 +644,7 @@
: >  
: >      foreach (@array[ 4 .. 10 ]) { s/peter/paul/ } 
: >  
: > -    foreach (@hash{keys %hash}) {
: > +    foreach (values %hash) {
: >          s/^\s+//;           # trim leading whitespace
: >          s/\s+$//;           # trim trailing whitespace
: >          s/(\w+)/\u\L$1/g;   # "titlecase" words
: 
: The problem is you're no longer demonstrating that the results of a hash
: slice is an lvalue.
: 
: Maybe:
: 
:       foreach (@hash{qw/title subtitle/}) {

Indeed, I was too quick to judge the dubious construct.  Here is a
better patch.


  Casey West

-- 
"Louis Pasteur's theory of germs is ridiculous fiction".
 -- Pierre Pachet, Professor of Physiology at Toulouse, 1872

--- perl-current.orig/pod/perldata.pod  Mon Mar  4 04:18:27 2002
+++ perl-current/pod/perldata.pod       Thu Apr 24 21:22:01 2003
@@ -644,7 +644,7 @@
 
     foreach (@array[ 4 .. 10 ]) { s/peter/paul/ } 
 
-    foreach (@hash{keys %hash}) {
+    foreach (@hash{qw[key1 key2]}) {
         s/^\s+//;           # trim leading whitespace
         s/\s+$//;           # trim trailing whitespace
         s/(\w+)/\u\L$1/g;   # "titlecase" words

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About