summaryrefslogtreecommitdiff
path: root/pod/perlstyle.pod
diff options
context:
space:
mode:
authorDan Book <grinnz@grinnz.com>2019-08-28 18:41:34 -0400
committerKarl Williamson <khw@cpan.org>2019-08-30 08:37:23 -0600
commit3f1e98f5a21968dcf33fdecdc51b0ff9b485f86a (patch)
treee388734d953b283271cef4f18c84fd4b33614927 /pod/perlstyle.pod
parent803b7faa4a2e676adbffb7deae13e2584c1e5398 (diff)
downloadperl-3f1e98f5a21968dcf33fdecdc51b0ff9b485f86a.tar.gz
Avoid 2 arg open and bareword handles
Diffstat (limited to 'pod/perlstyle.pod')
-rw-r--r--pod/perlstyle.pod6
1 files changed, 3 insertions, 3 deletions
diff --git a/pod/perlstyle.pod b/pod/perlstyle.pod
index 1f64b9ec3c..adc0f0d69f 100644
--- a/pod/perlstyle.pod
+++ b/pod/perlstyle.pod
@@ -103,11 +103,11 @@ you I<SHOULD> do it that way. Perl is designed to give you several
ways to do anything, so consider picking the most readable one. For
instance
- open(FOO,$foo) || die "Can't open $foo: $!";
+ open(my $fh, '<', $foo) || die "Can't open $foo: $!";
is better than
- die "Can't open $foo: $!" unless open(FOO,$foo);
+ die "Can't open $foo: $!" unless open(my $fh, '<', $foo);
because the second way hides the main point of the statement in a
modifier. On the other hand
@@ -249,7 +249,7 @@ system call and arguments were, and (VERY IMPORTANT) should contain the
standard system error message for what went wrong. Here's a simple but
sufficient example:
- opendir(D, $dir) or die "can't opendir $dir: $!";
+ opendir(my $dh, $dir) or die "can't opendir $dir: $!";
=item *