From: Casey West Date: Fri, 25 Apr 2003 10:46:39 +0000 (-0400) Subject: Some doc patches by Casey West : X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=00cb5da129a8590d61ea16748bc9227b1757d0bf;p=p5sagit%2Fp5-mst-13.2.git Some doc patches by Casey West : Subject: Re: [PATCH] Re: [perl #21260] adding error handling info to perlfunc/readline Date: Fri, 25 Apr 2003 10:46:39 -0400 Message-ID: <20030425144639.GY34510@geeknest.com> Subject: Re: [perl #21785] [PATCH] clarify readdir in for conditional From: Casey West Date: Fri, 25 Apr 2003 07:52:13 -0400 Message-ID: <20030425115213.GP34510@geeknest.com> Subject: Re: [perl #7213] [PATCH] Updating example in perldata From: Casey West Date: Thu, 24 Apr 2003 21:27:22 -0400 Message-ID: <20030425012722.GN34510@geeknest.com> p4raw-id: //depot/perl@19344 --- diff --git a/pod/perldata.pod b/pod/perldata.pod index 8e2e177..5720589 100644 --- a/pod/perldata.pod +++ b/pod/perldata.pod @@ -644,7 +644,7 @@ values of the array or hash. 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 diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 721b890..70e604b 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -3834,6 +3834,21 @@ operator is discussed in more detail in L. $line = ; $line = readline(*STDIN); # same thing +If readline encounters an operating system error, C<$!> will be set with the +corresponding error message. It can be helpful to check C<$!> when you are +reading from filehandles you don't trust, such as a tty or a socket. The +following example uses the operator form of C, and takes the necessary +steps to ensure that C was successful. + + for (;;) { + undef $!; + unless (defined( $line = <> )) { + die $! if $!; + last; # reached EOF + } + # ... + } + =item readlink EXPR =item readlink diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod index 16bca2d..1b5a6a9 100644 --- a/pod/perlsyn.pod +++ b/pod/perlsyn.pod @@ -315,6 +315,14 @@ hang. # do something } +Using C (or the operator form, C<< >>) as the +conditional of a C loop is shorthand for the following. This +behaviour is the same as a C loop conditional. + + for ( prompt(); defined( $_ = ); prompt() ) { + # do something + } + =head2 Foreach Loops The C loop iterates over a normal list value and sets the