Change 32729 by [EMAIL PROTECTED] on 2007/12/26 14:55:03
Subject: [PATCH] docs: replace FH by my $fh in open
From: "Gabor Szabo" <[EMAIL PROTECTED]>
Date: Wed, 26 Dec 2007 06:03:29 +0200
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/pod/perlfunc.pod#585 edit
Differences ...
==== //depot/perl/pod/perlfunc.pod#585 (text) ====
Index: perl/pod/perlfunc.pod
--- perl/pod/perlfunc.pod#584~32692~ 2007-12-21 09:58:03.000000000 -0800
+++ perl/pod/perlfunc.pod 2007-12-26 06:55:03.000000000 -0800
@@ -3057,6 +3057,14 @@
Opens the file whose filename is given by EXPR, and associates it with
FILEHANDLE.
+Simple examples to open a file for reading:
+
+ open(my $fh, '<', "input.txt") or die $!;
+
+and for writing:
+
+ open(my $fh, '>', "output.txt") or die $!;
+
(The following is a comprehensive reference to open(): for a gentler
introduction you may consider L<perlopentut>.)
@@ -3128,7 +3136,7 @@
that affect how the input and output are processed (see L<open> and
L<PerlIO> for more details). For example
- open(FH, "<:encoding(UTF-8)", "file")
+ open(my $fh, "<:encoding(UTF-8)", "file")
will open the UTF-8 encoded file containing Unicode characters,
see L<perluniintro>. Note that if layers are specified in the
@@ -3158,7 +3166,7 @@
As a special case the 3-arg form with a read/write mode and the third
argument being C<undef>:
- open(TMP, "+>", undef) or die ...
+ open(my $tmp, "+>", undef) or die ...
opens a filehandle to an anonymous temporary file. Also using "+<"
works for symmetry, but you really should consider writing something
@@ -3186,10 +3194,10 @@
open(LOG, '>>/usr/spool/news/twitlog'); # (log is reserved)
# if the open fails, output is discarded
- open(DBASE, '+<', 'dbase.mine') # open for update
+ open(my $dbase, '+<', 'dbase.mine') # open for update
or die "Can't open 'dbase.mine' for update: $!";
- open(DBASE, '+<dbase.mine') # ditto
+ open(my $dbase, '+<dbase.mine') # ditto
or die "Can't open 'dbase.mine' for update: $!";
open(ARTICLE, '-|', "caesar <$article") # decrypt article
End of Patch.