In perl.git, the branch blead has been updated

<https://perl5.git.perl.org/perl.git/commitdiff/3f1e98f5a21968dcf33fdecdc51b0ff9b485f86a?hp=3b2e5620ed4a6b341f97ffd1d4b6466cc2c4bc5b>

- Log -----------------------------------------------------------------
commit 3f1e98f5a21968dcf33fdecdc51b0ff9b485f86a
Author: Dan Book <[email protected]>
Date:   Wed Aug 28 18:41:34 2019 -0400

    Avoid 2 arg open and bareword handles

commit 803b7faa4a2e676adbffb7deae13e2584c1e5398
Author: Dan Book <[email protected]>
Date:   Wed Aug 28 18:34:51 2019 -0400

    Rewrite paragraph on using strict and warnings

-----------------------------------------------------------------------

Summary of changes:
 pod/perlstyle.pod | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/pod/perlstyle.pod b/pod/perlstyle.pod
index 5c2534581e..adc0f0d69f 100644
--- a/pod/perlstyle.pod
+++ b/pod/perlstyle.pod
@@ -8,12 +8,13 @@ Each programmer will, of course, have his or her own 
preferences in
 regards to formatting, but there are some general guidelines that will
 make your programs easier to read, understand, and maintain.
 
-The most important thing is to run your programs under the B<-w>
-flag at all times.  You may turn it off explicitly for particular
-portions of code via the C<no warnings> pragma or the C<$^W> variable
-if you must.  You should also always run under C<use strict> or know the
-reason why not.  The C<use sigtrap> and even C<use diagnostics> pragmas
-may also prove useful.
+The most important thing is to use L<strict> and L<warnings> in all your
+code or know the reason why not to.  You may turn them off explicitly for
+particular portions of code via C<no warnings> or C<no strict>, and this
+can be limited to the specific warnings or strict features you wish to
+disable.  The B<-w> flag and C<$^W> variable should not be used for this
+purpose since they can affect code you use but did not write, such as
+modules from core or CPAN.
 
 Regarding aesthetics of code lay out, about the only thing Larry
 cares strongly about is that the closing curly bracket of
@@ -102,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
@@ -248,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 *
 
@@ -262,7 +263,7 @@ Line up your transliterations when it makes sense:
 Think about reusability.  Why waste brainpower on a one-shot when you
 might want to do something like it again?  Consider generalizing your
 code.  Consider writing a module or object class.  Consider making your
-code run cleanly with C<use strict> and C<use warnings> (or B<-w>) in
+code run cleanly with C<use strict> and C<use warnings> in
 effect.  Consider giving away your code.  Consider changing your whole
 world view.  Consider... oh, never mind.
 

-- 
Perl5 Master Repository

Reply via email to