summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2022-04-06 12:47:26 +0100
committerPaul Evans <leonerd@leonerd.org.uk>2022-04-23 20:09:59 +0100
commitd84bd0bd478e7c7ff7f57eeb94fda30ee0e34296 (patch)
treecd959fade4d460df6a04e1895c51756aee4d8c7f
parent6901d503782a626a02477c4142ee3b88483786dd (diff)
downloadperl-d84bd0bd478e7c7ff7f57eeb94fda30ee0e34296.tar.gz
Replace 'use strict; use warnings;' with 'use VERSION' in docs code examples
-rw-r--r--pod/perldbmfilter.pod6
-rw-r--r--pod/perldebtut.pod4
-rw-r--r--pod/perlfilter.pod3
-rw-r--r--pod/perlfunc.pod6
-rw-r--r--pod/perlipc.pod45
-rw-r--r--pod/perlmod.pod3
-rw-r--r--pod/perlobj.pod6
-rw-r--r--pod/perlperf.pod21
-rw-r--r--pod/perlpragma.pod6
-rw-r--r--pod/perlthrtut.pod85
-rw-r--r--pod/perltie.pod3
-rw-r--r--pod/perlunicook.pod24
-rw-r--r--t/porting/customized.dat2
13 files changed, 87 insertions, 127 deletions
diff --git a/pod/perldbmfilter.pod b/pod/perldbmfilter.pod
index 4130a9f2a3..f804cb84cb 100644
--- a/pod/perldbmfilter.pod
+++ b/pod/perldbmfilter.pod
@@ -84,8 +84,7 @@ the database and have them removed when you read from the database. As I'm
sure you have already guessed, this is a problem that DBM Filters can
fix very easily.
- use strict;
- use warnings;
+ use v5.36;
use SDBM_File;
use Fcntl;
@@ -132,8 +131,7 @@ when reading.
Here is a DBM Filter that does it:
- use strict;
- use warnings;
+ use v5.36;
use DB_File;
my %hash;
my $filename = "filt";
diff --git a/pod/perldebtut.pod b/pod/perldebtut.pod
index 83e524fad3..364e51560d 100644
--- a/pod/perldebtut.pod
+++ b/pod/perldebtut.pod
@@ -421,8 +421,8 @@ For more on references see L<perlref> and L<perlreftut>
Here's a simple program which converts between Celsius and Fahrenheit, it too
has a problem:
- #!/usr/bin/perl -w
- use strict;
+ #!/usr/bin/perl
+ use v5.36;
my $arg = $ARGV[0] || '-c20';
diff --git a/pod/perlfilter.pod b/pod/perlfilter.pod
index c137266292..60be3df0d5 100644
--- a/pod/perlfilter.pod
+++ b/pod/perlfilter.pod
@@ -410,8 +410,7 @@ Here is the complete Debug filter:
package Debug;
- use strict;
- use warnings;
+ use v5.36;
use Filter::Util::Call;
use constant TRUE => 1;
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 23431b96a1..fa73276af2 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -5119,7 +5119,7 @@ L<C<our>|/our VARLIST> declaration. This applies immediately--even
within the same statement.
package Foo;
- use strict;
+ use v5.36; # which implies "use strict;"
$Foo::foo = 23;
@@ -5136,7 +5136,7 @@ This works even if the package variable has not been used before, as
package variables spring into existence when first used.
package Foo;
- use strict;
+ use v5.36;
our $foo = 23; # just like $Foo::foo = 23
@@ -5147,7 +5147,7 @@ long as there is no variable with that name is already in scope, you can then
reference the package variable again even within the same statement.
package Foo;
- use strict;
+ use v5.36;
my $foo = $foo; # error, undeclared $foo on right-hand side
our $foo = $foo; # no errors
diff --git a/pod/perlipc.pod b/pod/perlipc.pod
index 7040ab17d0..840c2719b0 100644
--- a/pod/perlipc.pod
+++ b/pod/perlipc.pod
@@ -190,8 +190,7 @@ info to show that it works; it should be replaced with the real code.
#!/usr/bin/perl
- use strict;
- use warnings;
+ use v5.36;
use POSIX ();
use FindBin ();
@@ -834,8 +833,7 @@ reopen the appropriate handles to STDIN and STDOUT and call other processes.
#!/usr/bin/perl
# pipe1 - bidirectional communication using two pipe pairs
# designed for the socketpair-challenged
- use strict;
- use warnings;
+ use v5.36;
use IO::Handle; # enable autoflush method before Perl 5.14
pipe(my $parent_rdr, my $child_wtr); # XXX: check failure?
pipe(my $child_rdr, my $parent_wtr); # XXX: check failure?
@@ -869,8 +867,7 @@ have the socketpair() system call, it will do this all for you.
# pipe2 - bidirectional communication using socketpair
# "the best ones always go both ways"
- use strict;
- use warnings;
+ use v5.36;
use Socket;
use IO::Handle; # enable autoflush method before Perl 5.14
@@ -950,8 +947,7 @@ communication that might extend to machines outside of your own system.
Here's a sample TCP client using Internet-domain sockets:
#!/usr/bin/perl
- use strict;
- use warnings;
+ use v5.36;
use Socket;
my $remote = shift || "localhost";
@@ -978,8 +974,7 @@ on a particular interface (like the external side of a gateway
or firewall machine), fill this in with your real address instead.
#!/usr/bin/perl -T
- use strict;
- use warnings;
+ use v5.36;
BEGIN { $ENV{PATH} = "/usr/bin:/bin" }
use Socket;
use Carp;
@@ -1018,8 +1013,7 @@ handle the client request so that the master server can quickly
go back to service a new client.
#!/usr/bin/perl -T
- use strict;
- use warnings;
+ use v5.36;
BEGIN { $ENV{PATH} = "/usr/bin:/bin" }
use Socket;
use Carp;
@@ -1147,8 +1141,7 @@ service on a number of different machines and shows how far their clocks
differ from the system on which it's being run:
#!/usr/bin/perl
- use strict;
- use warnings;
+ use v5.36;
use Socket;
my $SECS_OF_70_YEARS = 2208988800;
@@ -1196,9 +1189,8 @@ You can test for these with Perl's B<-S> file test:
Here's a sample Unix-domain client:
#!/usr/bin/perl
+ use v5.36;
use Socket;
- use strict;
- use warnings;
my $rendezvous = shift || "catsock";
socket(my $sock, PF_UNIX, SOCK_STREAM, 0) || die "socket: $!";
@@ -1213,8 +1205,7 @@ network terminators here because Unix domain sockets are guaranteed
to be on the localhost, and thus everything works right.
#!/usr/bin/perl -T
- use strict;
- use warnings;
+ use v5.36;
use Socket;
use Carp;
@@ -1321,8 +1312,7 @@ service at port 13 of the host name "localhost" and prints out everything
that the server there cares to provide.
#!/usr/bin/perl
- use strict;
- use warnings;
+ use v5.36;
use IO::Socket;
my $remote = IO::Socket::INET->new(
Proto => "tcp",
@@ -1377,8 +1367,7 @@ more interesting client than the previous one because it first sends
something to the server before fetching the server's response.
#!/usr/bin/perl
- use strict;
- use warnings;
+ use v5.36;
use IO::Socket;
unless (@ARGV > 1) { die "usage: $0 host url ..." }
my $host = shift(@ARGV);
@@ -1458,8 +1447,7 @@ well, which is probably why it's spread to other systems.)
Here's the code:
#!/usr/bin/perl
- use strict;
- use warnings;
+ use v5.36;
use IO::Socket;
unless (@ARGV == 2) { die "usage: $0 host port" }
@@ -1573,8 +1561,7 @@ Chapter 16 of the Camel.
Here's the code.
#!/usr/bin/perl
- use strict;
- use warnings;
+ use v5.36;
use IO::Socket;
use Net::hostent; # for OOish version of gethostbyaddr
@@ -1635,8 +1622,7 @@ using select() to do a timed-out wait for I/O. To do something similar
with TCP, you'd have to use a different socket handle for each host.
#!/usr/bin/perl
- use strict;
- use warnings;
+ use v5.36;
use Socket;
use Sys::Hostname;
@@ -1804,8 +1790,7 @@ programs this way for optimal success, and don't forget to add the B<-T>
taint-checking flag to the C<#!> line for servers:
#!/usr/bin/perl -T
- use strict;
- use warnings;
+ use v5.36;
use sigtrap;
use Socket;
diff --git a/pod/perlmod.pod b/pod/perlmod.pod
index e1fc952e28..5c68273820 100644
--- a/pod/perlmod.pod
+++ b/pod/perlmod.pod
@@ -448,8 +448,7 @@ create a file called F<Some/Module.pm> and start with this template:
package Some::Module; # assumes Some/Module.pm
- use strict;
- use warnings;
+ use v5.36;
# Get the import method from Exporter to export functions and
# variables
diff --git a/pod/perlobj.pod b/pod/perlobj.pod
index dddf78abaf..2fb80355a3 100644
--- a/pod/perlobj.pod
+++ b/pod/perlobj.pod
@@ -1011,8 +1011,7 @@ Here's an example of a module as a blessed scalar:
package Time;
- use strict;
- use warnings;
+ use v5.36;
sub new {
my $class = shift;
@@ -1050,8 +1049,7 @@ to support inside-out object implementations.
package Time;
- use strict;
- use warnings;
+ use v5.36;
use Hash::Util::FieldHash 'fieldhash';
diff --git a/pod/perlperf.pod b/pod/perlperf.pod
index 13ad0a313b..1aa17029e6 100644
--- a/pod/perlperf.pod
+++ b/pod/perlperf.pod
@@ -126,8 +126,7 @@ comparative code in a file and running a C<Benchmark> test.
#!/usr/bin/perl
- use strict;
- use warnings;
+ use v5.36;
use Benchmark;
@@ -193,8 +192,7 @@ noticing it's assigned only the once.
#!/usr/bin/perl
- use strict;
- use warnings;
+ use v5.36;
use Benchmark;
@@ -229,8 +227,7 @@ report on the contents.
#!/usr/bin/perl
- use strict;
- use warnings;
+ use v5.36;
=head1 NAME
@@ -815,8 +812,7 @@ command-line.
#!/usr/bin/perl -n
- use strict;
- use warnings;
+ use v5.36;
my @data;
@@ -910,8 +906,7 @@ input directly as it arrives too. Otherwise, the code looks fairly similar:
#!/usr/bin/perl -n
- use strict;
- use warnings;
+ use v5.36;
print
@@ -998,8 +993,7 @@ including a C<debug()> subroutine to emulate typical C<logger()> functionality.
#!/usr/bin/perl
- use strict;
- use warnings;
+ use v5.36;
use Benchmark;
use Data::Dumper;
@@ -1045,8 +1039,7 @@ time C<DEBUG> constant.
#!/usr/bin/perl
- use strict;
- use warnings;
+ use v5.36;
use Benchmark;
use Data::Dumper;
diff --git a/pod/perlpragma.pod b/pod/perlpragma.pod
index 78dacbf174..20299a880e 100644
--- a/pod/perlpragma.pod
+++ b/pod/perlpragma.pod
@@ -51,8 +51,7 @@ The minimal implementation of the package C<MyMaths> would be something like
this:
package MyMaths;
- use warnings;
- use strict;
+ use v5.36;
use myint();
use overload '+' => sub {
my ($l, $r) = @_;
@@ -78,8 +77,7 @@ The interaction with the Perl compilation happens inside package C<myint>:
package myint;
- use strict;
- use warnings;
+ use v5.36;
sub import {
$^H{"myint/in_effect"} = 1;
diff --git a/pod/perlthrtut.pod b/pod/perlthrtut.pod
index a8560dd54f..78d6030406 100644
--- a/pod/perlthrtut.pod
+++ b/pod/perlthrtut.pod
@@ -852,37 +852,36 @@ things we've covered. This program finds prime numbers using threads.
1 #!/usr/bin/perl
2 # prime-pthread, courtesy of Tom Christiansen
3
- 4 use strict;
- 5 use warnings;
- 6
- 7 use threads;
- 8 use Thread::Queue;
- 9
- 10 sub check_num {
- 11 my ($upstream, $cur_prime) = @_;
- 12 my $kid;
- 13 my $downstream = Thread::Queue->new();
- 14 while (my $num = $upstream->dequeue()) {
- 15 next unless ($num % $cur_prime);
- 16 if ($kid) {
- 17 $downstream->enqueue($num);
- 18 } else {
- 19 print("Found prime: $num\n");
- 20 $kid = threads->create(\&check_num, $downstream, $num);
- 21 if (! $kid) {
- 22 warn("Sorry. Ran out of threads.\n");
- 23 last;
- 24 }
- 25 }
- 26 }
- 27 if ($kid) {
- 28 $downstream->enqueue(undef);
- 29 $kid->join();
- 30 }
- 31 }
- 32
- 33 my $stream = Thread::Queue->new(3..1000, undef);
- 34 check_num($stream, 2);
+ 4 use v5.36;
+ 5
+ 6 use threads;
+ 7 use Thread::Queue;
+ 8
+ 9 sub check_num {
+ 10 my ($upstream, $cur_prime) = @_;
+ 11 my $kid;
+ 12 my $downstream = Thread::Queue->new();
+ 13 while (my $num = $upstream->dequeue()) {
+ 14 next unless ($num % $cur_prime);
+ 15 if ($kid) {
+ 16 $downstream->enqueue($num);
+ 17 } else {
+ 18 print("Found prime: $num\n");
+ 19 $kid = threads->create(\&check_num, $downstream, $num);
+ 20 if (! $kid) {
+ 21 warn("Sorry. Ran out of threads.\n");
+ 22 last;
+ 23 }
+ 24 }
+ 25 }
+ 26 if ($kid) {
+ 27 $downstream->enqueue(undef);
+ 28 $kid->join();
+ 29 }
+ 30 }
+ 31
+ 32 my $stream = Thread::Queue->new(3..1000, undef);
+ 33 check_num($stream, 2);
This program uses the pipeline model to generate prime numbers. Each
thread in the pipeline has an input queue that feeds numbers to be
@@ -901,32 +900,32 @@ number is, it's a number that's only evenly divisible by itself and 1.)
The bulk of the work is done by the C<check_num()> subroutine, which
takes a reference to its input queue and a prime number that it's
responsible for. After pulling in the input queue and the prime that
-the subroutine is checking (line 11), we create a new queue (line 13)
+the subroutine is checking (line 10), we create a new queue (line 12)
and reserve a scalar for the thread that we're likely to create later
-(line 12).
+(line 11).
-The while loop from line 14 to line 26 grabs a scalar off the input
+The while loop from line 13 to line 25 grabs a scalar off the input
queue and checks against the prime this thread is responsible
-for. Line 15 checks to see if there's a remainder when we divide the
+for. Line 14 checks to see if there's a remainder when we divide the
number to be checked by our prime. If there is one, the number
must not be evenly divisible by our prime, so we need to either pass
-it on to the next thread if we've created one (line 17) or create a
+it on to the next thread if we've created one (line 16) or create a
new thread if we haven't.
-The new thread creation is line 20. We pass on to it a reference to
-the queue we've created, and the prime number we've found. In lines 21
-through 24, we check to make sure that our new thread got created, and
+The new thread creation is line 19. We pass on to it a reference to
+the queue we've created, and the prime number we've found. In lines 20
+through 23, we check to make sure that our new thread got created, and
if not, we stop checking any remaining numbers in the queue.
Finally, once the loop terminates (because we got a 0 or C<undef> in the
queue, which serves as a note to terminate), we pass on the notice to our
-child, and wait for it to exit if we've created a child (lines 27 and
-30).
+child, and wait for it to exit if we've created a child (lines 26 and
+29).
-Meanwhile, back in the main thread, we first create a queue (line 33) and
+Meanwhile, back in the main thread, we first create a queue (line 32) and
queue up all the numbers from 3 to 1000 for checking, plus a termination
notice. Then all we have to do to get the ball rolling is pass the queue
-and the first prime to the C<check_num()> subroutine (line 34).
+and the first prime to the C<check_num()> subroutine (line 33).
That's how it works. It's pretty simple; as with many Perl programs,
the explanation is much longer than the program.
diff --git a/pod/perltie.pod b/pod/perltie.pod
index 9e8ad168f3..5e032aefeb 100644
--- a/pod/perltie.pod
+++ b/pod/perltie.pod
@@ -1070,8 +1070,7 @@ a scalar.
package Remember;
- use strict;
- use warnings;
+ use v5.36;
use IO::File;
sub TIESCALAR {
diff --git a/pod/perlunicook.pod b/pod/perlunicook.pod
index c709e0fc73..018d74c9a5 100644
--- a/pod/perlunicook.pod
+++ b/pod/perlunicook.pod
@@ -21,10 +21,9 @@ to work correctly, with the C<#!> adjusted to work on your system:
#!/usr/bin/env perl
+ use v5.36; # or later to get "unicode_strings" feature,
+ # plus strict, warnings
use utf8; # so literals and identifiers can be in UTF-8
- use v5.12; # or later to get "unicode_strings" feature
- use strict; # quote strings, declare variables
- use warnings; # on by default
use warnings qw(FATAL utf8); # fatalize encoding glitches
use open qw(:std :encoding(UTF-8)); # undeclared streams in UTF-8
use charnames qw(:full :short); # unneeded in v5.16
@@ -696,17 +695,15 @@ When run, the following program produces this nicely aligned output:
寿司............... €9.99
包子............... €7.50
-Here's that program; tested on v5.14.
+Here's that program.
#!/usr/bin/env perl
# umenu - demo sorting and printing of Unicode food
#
# (obligatory and increasingly long preamble)
#
+ use v5.36;
use utf8;
- use v5.14; # for locale sorting
- use strict;
- use warnings;
use warnings qw(FATAL utf8); # fatalize encoding faults
use open qw(:std :encoding(UTF-8)); # undeclared streams in UTF-8
use charnames qw(:full :short); # unneeded in v5.16
@@ -719,11 +716,6 @@ Here's that program; tested on v5.14.
# cpan modules
use Unicode::GCString; # from CPAN
- # forward defs
- sub pad($$$);
- sub colwidth(_);
- sub entitle(_);
-
my %price = (
"γύρος" => 6.50, # gyros
"pears" => 2.00, # like um, pears
@@ -747,7 +739,7 @@ Here's that program; tested on v5.14.
"お好み焼き" => 8.00, # okonomiyaki, Japanese
);
- my $width = 5 + max map { colwidth } keys %price;
+ my $width = 5 + max map { colwidth($_) } keys %price;
# So the Asian stuff comes out in an order that someone
# who reads those scripts won't freak out over; the
@@ -759,17 +751,17 @@ Here's that program; tested on v5.14.
printf " €%.2f\n", $price{$item};
}
- sub pad($$$) {
+ sub pad {
my($str, $width, $padchar) = @_;
return $str . ($padchar x ($width - colwidth($str)));
}
- sub colwidth(_) {
+ sub colwidth {
my($str) = @_;
return Unicode::GCString->new($str)->columns;
}
- sub entitle(_) {
+ sub entitle {
my($str) = @_;
$str =~ s{ (?=\pL)(\S) (\S*) }
{ ucfirst($1) . lc($2) }xge;
diff --git a/t/porting/customized.dat b/t/porting/customized.dat
index a793734a03..bb08c321f8 100644
--- a/t/porting/customized.dat
+++ b/t/porting/customized.dat
@@ -3,7 +3,7 @@
# ./perl -I../lib porting/customized.t --regen
ExtUtils::Constant cpan/ExtUtils-Constant/lib/ExtUtils/Constant/Base.pm 7560e1018f806db5689dee78728ccb8374aea741
ExtUtils::Constant cpan/ExtUtils-Constant/t/Constant.t 165e9c7132b003fd192d32a737b0f51f9ba4999e
-Filter::Util::Call pod/perlfilter.pod 2d98239c4f4a930ad165444c3879629bb91f4cef
+Filter::Util::Call pod/perlfilter.pod 545265af2f45741a0e59eecdd0cfc0c9e490c1e8
Locale::Maketext::Simple cpan/Locale-Maketext-Simple/lib/Locale/Maketext/Simple.pm 57ed38905791a17c150210cd6f42ead22a7707b6
Math::Complex cpan/Math-Complex/lib/Math/Complex.pm 66f28a17647e2de166909ca66e4ced26f8a0a62e
Math::Complex cpan/Math-Complex/t/Complex.t 17039e03ee798539e770ea9a0d19a99364278306