Skip to content

Commit

Permalink
Document v5.35 warnings-on-by-default
Browse files Browse the repository at this point in the history
  • Loading branch information
cornett authored and Leont committed Jul 31, 2021
1 parent 0dfd6a8 commit 69a3135
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 15 deletions.
8 changes: 7 additions & 1 deletion lib/warnings.pm
Expand Up @@ -5,7 +5,7 @@

package warnings;

our $VERSION = "1.52";
our $VERSION = "1.53";

# Verify that we're called correctly so that warnings will work.
# Can't use Carp, since Carp uses us!
Expand Down Expand Up @@ -580,6 +580,9 @@ warnings - Perl pragma to control optional warnings
use warnings;
no warnings;
# Standard warnings are enabled by use v5.35 or above
use v5.35;
use warnings "all";
no warnings "uninitialized";
Expand Down Expand Up @@ -645,6 +648,9 @@ block has them disabled. In this case that means the assignment to the
scalar C<$z> will trip the C<"Scalar value @x[0] better written as $x[0]">
warning, but the assignment to the scalar C<$y> will not.
All warnings are enabled automatically within the scope of
a C<L<use v5.35|perlfunc/use VERSION>> (or higher) declaration.
=head2 Default Warnings and Optional Warnings
Before the introduction of lexical warnings, Perl had two classes of
Expand Down
9 changes: 6 additions & 3 deletions pod/perl.pod
Expand Up @@ -393,10 +393,13 @@ see L<perlvar> for more information.

Using the C<use strict> pragma ensures that all variables are properly
declared and prevents other misuses of legacy Perl features.
These are enabled by default within the scope of
C<L<use v5.12|perlfunc/use VERSION>> (or higher).

The C<use warnings> pragma produces some lovely diagnostics. One can
also use the B<-w> flag, but its use is normally discouraged, because
it gets applied to all executed Perl code, including that not under
The C<use warnings> pragma produces some lovely diagnostics.
It is enabled by default when you say C<use v5.35> (or higher).
One can also use the B<-w> flag, but its use is normally discouraged,
because it gets applied to all executed Perl code, including that not under
your control.

See L<perldiag> for explanations of all Perl's diagnostics. The C<use
Expand Down
19 changes: 10 additions & 9 deletions pod/perlfunc.pod
Expand Up @@ -9638,18 +9638,19 @@ L<C<use>|/use Module VERSION LIST>ing library modules that won't work
with older versions of Perl.
(We try not to do this more than we have to.)

C<use VERSION> also lexically enables all features available in the requested
C<use VERSION> lexically enables all features available in the requested
version as defined by the L<feature> pragma, disabling any features
not in the requested version's feature bundle. See L<feature>.
Similarly, if the specified Perl version is greater than or equal to
If the specified Perl version is greater than or equal to
5.12.0, strictures are enabled lexically as
with L<C<use strict>|strict>. Any explicit use of
C<use strict> or C<no strict> overrides C<use VERSION>, even if it comes
before it. Later use of C<use VERSION>
will override all behavior of a previous
C<use VERSION>, possibly removing the C<strict> and C<feature> added by
C<use VERSION>. C<use VERSION> does not
load the F<feature.pm> or F<strict.pm>
with L<C<use strict>|strict>.
Similarly, L<warnings> are enabled if C<VERSION> is 5.35.0 or higher.
Any explicit use of C<use strict> or C<no strict> overrides C<use VERSION>,
even if it comes before it.
Later use of C<use VERSION> will override all behavior of a previous
C<use VERSION>, possibly removing the C<strict>, C<warnings>, and C<feature>
added by C<use VERSION>. C<use VERSION> does not
load the F<feature.pm>, F<strict.pm>, or F<warnings.pm>
files.

The C<BEGIN> forces the L<C<require>|/require VERSION> and
Expand Down
8 changes: 7 additions & 1 deletion pod/perlintro.pod
Expand Up @@ -93,9 +93,15 @@ problems in your code. They check different things so you need both. A
potential problem caught by C<use strict;> will cause your code to stop
immediately when it is encountered, while C<use warnings;> will merely
give a warning (like the command-line switch B<-w>) and let your code run.
To read more about them check their respective manual pages at L<strict>
To read more about them, check their respective manual pages at L<strict>
and L<warnings>.

A C<L<use v5.35|perlfunc/use VERSION>> (or higher) declaration will
enable both C<strict> and C<warnings>:

#!/usr/bin/perl
use v5.35;

=head2 Basic syntax overview

A Perl script or program consists of one or more statements. These
Expand Down
8 changes: 7 additions & 1 deletion regen/warnings.pl
Expand Up @@ -16,7 +16,7 @@
#
# This script is normally invoked from regen.pl.

$VERSION = '1.52';
$VERSION = '1.53';

BEGIN {
require './regen/regen_lib.pl';
Expand Down Expand Up @@ -882,6 +882,9 @@ =head1 SYNOPSIS
use warnings;
no warnings;
# Standard warnings are enabled by use v5.35 or above
use v5.35;
use warnings "all";
no warnings "uninitialized";
Expand Down Expand Up @@ -947,6 +950,9 @@ =head1 DESCRIPTION
scalar C<$z> will trip the C<"Scalar value @x[0] better written as $x[0]">
warning, but the assignment to the scalar C<$y> will not.
All warnings are enabled automatically within the scope of
a C<L<use v5.35|perlfunc/use VERSION>> (or higher) declaration.
=head2 Default Warnings and Optional Warnings
Before the introduction of lexical warnings, Perl had two classes of
Expand Down

0 comments on commit 69a3135

Please sign in to comment.