diff options
author | Dan Book <grinnz@grinnz.com> | 2020-04-01 13:04:35 -0400 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-04-01 14:06:34 -0600 |
commit | 45f87e658628cd0ee4595d39ffbf774a44c72a1f (patch) | |
tree | c9139a9d7ca02e268e28cafbacc10d12efcfb36a | |
parent | 5de22a40933c620b62e1f431457593777b99793d (diff) | |
download | perl-45f87e658628cd0ee4595d39ffbf774a44c72a1f.tar.gz |
warnings.pm - Clarify scoping of $^W examples
-rw-r--r-- | lib/warnings.pm | 6 | ||||
-rw-r--r-- | regen/warnings.pl | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/warnings.pm b/lib/warnings.pm index d434dcd36c..a70c25f125 100644 --- a/lib/warnings.pm +++ b/lib/warnings.pm @@ -5,7 +5,7 @@ package warnings; -our $VERSION = "1.46"; +our $VERSION = "1.47"; # Verify that we're called correctly so that warnings will work. # Can't use Carp, since Carp uses us! @@ -689,6 +689,10 @@ disable compile-time warnings you need to rewrite the code like this: my $b; chop $b; } +And note that unlike the first example, this will permanently set C<$^W> +since it cannot both run during compile-time and be localized to a +run-time block. + The other big problem with C<$^W> is the way you can inadvertently change the warning setting in unexpected places in your code. For example, when the code below is run (without the B<-w> flag), the second call diff --git a/regen/warnings.pl b/regen/warnings.pl index 6000c759ef..9fbf607d7a 100644 --- a/regen/warnings.pl +++ b/regen/warnings.pl @@ -16,7 +16,7 @@ # # This script is normally invoked from regen.pl. -$VERSION = '1.46'; +$VERSION = '1.47'; BEGIN { require './regen/regen_lib.pl'; @@ -1012,6 +1012,10 @@ disable compile-time warnings you need to rewrite the code like this: my $b; chop $b; } +And note that unlike the first example, this will permanently set C<$^W> +since it cannot both run during compile-time and be localized to a +run-time block. + The other big problem with C<$^W> is the way you can inadvertently change the warning setting in unexpected places in your code. For example, when the code below is run (without the B<-w> flag), the second call |