From: Ronald J. Kimball Date: Fri, 21 Sep 2001 12:34:40 +0000 (-0400) Subject: avoid v-strings with require/use X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3b825e419da1c361eab06a1e6d287276c0aef241;p=p5sagit%2Fp5-mst-13.2.git avoid v-strings with require/use Message-Id: <20010921123440.A148500@linguist.thayer.dartmouth.edu> p4raw-id: //depot/perl@12113 --- diff --git a/ext/ByteLoader/bytecode.h b/ext/ByteLoader/bytecode.h index e7ac6c8..73f3544 100644 --- a/ext/ByteLoader/bytecode.h +++ b/ext/ByteLoader/bytecode.h @@ -205,7 +205,7 @@ typedef IV IV64; bset_obj_store(aTHX_ bstate, obj, (I32)ix) : (bstate->bs_obj_list[ix] = obj) /* NOTE: the bytecode header only sanity-checks the bytecode. If a script cares about - * what version of Perl it's being called under, it should do a 'require 5.6.0' or + * what version of Perl it's being called under, it should do a 'use 5.006_001' or * equivalent. However, since the header includes checks requiring an exact match in * ByteLoader versions (we can't guarantee forward compatibility), you don't * need to specify one: diff --git a/ext/Data/Dumper/Dumper.pm b/ext/Data/Dumper/Dumper.pm index 5897e1f..6cf7d35 100644 --- a/ext/Data/Dumper/Dumper.pm +++ b/ext/Data/Dumper/Dumper.pm @@ -13,7 +13,7 @@ $VERSION = '2.103'; #$| = 1; -require 5.6.1; +use 5.006_001; require Exporter; use XSLoader (); require overload; diff --git a/ext/Devel/DProf/DProf.pm b/ext/Devel/DProf/DProf.pm index 6eb4c22..d5d8a82 100644 --- a/ext/Devel/DProf/DProf.pm +++ b/ext/Devel/DProf/DProf.pm @@ -1,4 +1,4 @@ -require 5.6.1; +use 5.006_001; =head1 NAME diff --git a/ext/IO/lib/IO/Dir.pm b/ext/IO/lib/IO/Dir.pm index d09eb7f..0a083ef 100644 --- a/ext/IO/lib/IO/Dir.pm +++ b/ext/IO/lib/IO/Dir.pm @@ -6,7 +6,7 @@ package IO::Dir; -use 5.6.0; +use 5.006; use strict; use Carp; diff --git a/ext/IO/lib/IO/File.pm b/ext/IO/lib/IO/File.pm index 83699fb..240033f 100644 --- a/ext/IO/lib/IO/File.pm +++ b/ext/IO/lib/IO/File.pm @@ -103,7 +103,7 @@ Derived from FileHandle.pm by Graham Barr EFE. =cut -require 5.6.1; +use 5.006_001; use strict; our($VERSION, @EXPORT, @EXPORT_OK, @ISA); use Carp; diff --git a/ext/IO/lib/IO/Handle.pm b/ext/IO/lib/IO/Handle.pm index 37aa99c..6fdba17 100644 --- a/ext/IO/lib/IO/Handle.pm +++ b/ext/IO/lib/IO/Handle.pm @@ -247,7 +247,7 @@ Derived from FileHandle.pm by Graham Barr EFE =cut -require 5.6.1; +use 5.006_001; use strict; our($VERSION, @EXPORT_OK, @ISA); use Carp; diff --git a/ext/IO/lib/IO/Pipe.pm b/ext/IO/lib/IO/Pipe.pm index 27747ce..a500f29 100644 --- a/ext/IO/lib/IO/Pipe.pm +++ b/ext/IO/lib/IO/Pipe.pm @@ -6,7 +6,7 @@ package IO::Pipe; -require 5.6.1; +use 5.006_001; use IO::Handle; use strict; diff --git a/ext/IO/lib/IO/Seekable.pm b/ext/IO/lib/IO/Seekable.pm index 987cbc3..684b8bc 100644 --- a/ext/IO/lib/IO/Seekable.pm +++ b/ext/IO/lib/IO/Seekable.pm @@ -94,7 +94,7 @@ Derived from FileHandle.pm by Graham Barr Egbarr@pobox.comE =cut -require 5.6.1; +use 5.006_001; use Carp; use strict; our($VERSION, @EXPORT, @ISA); diff --git a/ext/Opcode/Opcode.pm b/ext/Opcode/Opcode.pm index 544b284..1524f67 100644 --- a/ext/Opcode/Opcode.pm +++ b/ext/Opcode/Opcode.pm @@ -1,6 +1,6 @@ package Opcode; -require 5.6.1; +use 5.006_001; use strict; diff --git a/lib/AnyDBM_File.pm b/lib/AnyDBM_File.pm index 476df47..d73abab 100644 --- a/lib/AnyDBM_File.pm +++ b/lib/AnyDBM_File.pm @@ -1,6 +1,6 @@ package AnyDBM_File; -use 5.6.1; +use 5.006_001; our $VERSION = '1.00'; our @ISA = qw(NDBM_File DB_File GDBM_File SDBM_File ODBM_File) unless @ISA; diff --git a/lib/AutoLoader.pm b/lib/AutoLoader.pm index 4e1eb1b..b42d5ff 100644 --- a/lib/AutoLoader.pm +++ b/lib/AutoLoader.pm @@ -1,6 +1,6 @@ package AutoLoader; -use 5.6.0; +use 5.006_001; our(@EXPORT, @EXPORT_OK, $VERSION); my $is_dosish; diff --git a/lib/AutoSplit.pm b/lib/AutoSplit.pm index 281d5c6..ae119d3 100644 --- a/lib/AutoSplit.pm +++ b/lib/AutoSplit.pm @@ -1,6 +1,6 @@ package AutoSplit; -use 5.6.1; +use 5.006_001; use Exporter (); use Config qw(%Config); use Carp qw(carp); diff --git a/lib/Class/Struct.pm b/lib/Class/Struct.pm index ee23190..bad4f78 100644 --- a/lib/Class/Struct.pm +++ b/lib/Class/Struct.pm @@ -2,7 +2,7 @@ package Class::Struct; ## See POD after __END__ -use 5.6.1; +use 5.006_001; use strict; use warnings::register; diff --git a/lib/Cwd.pm b/lib/Cwd.pm index 8b9a780..01f5ce4 100644 --- a/lib/Cwd.pm +++ b/lib/Cwd.pm @@ -1,5 +1,5 @@ package Cwd; -require 5.6.0; +use 5.006; =head1 NAME diff --git a/lib/Dumpvalue.pm b/lib/Dumpvalue.pm index 456261a..427f57c 100644 --- a/lib/Dumpvalue.pm +++ b/lib/Dumpvalue.pm @@ -1,4 +1,4 @@ -use 5.6.1; # for (defined ref) and $#$v and our +use 5.006_001; # for (defined ref) and $#$v and our package Dumpvalue; use strict; our $VERSION = '1.00'; diff --git a/lib/ExtUtils/Command.pm b/lib/ExtUtils/Command.pm index b7b41cd..bf1e0e5 100644 --- a/lib/ExtUtils/Command.pm +++ b/lib/ExtUtils/Command.pm @@ -1,6 +1,6 @@ package ExtUtils::Command; -use 5.6.1; +use 5.006_001; use strict; # use AutoLoader; use Carp; diff --git a/lib/ExtUtils/Install.pm b/lib/ExtUtils/Install.pm index d701042..14a6e08 100644 --- a/lib/ExtUtils/Install.pm +++ b/lib/ExtUtils/Install.pm @@ -1,6 +1,6 @@ package ExtUtils::Install; -use 5.6.1; +use 5.006_001; our(@ISA, @EXPORT, $VERSION); $VERSION = substr q$Revision: 1.29 $, 10; # $Date: 1998/01/25 07:08:24 $ diff --git a/lib/ExtUtils/Installed.pm b/lib/ExtUtils/Installed.pm index 942185e..7433c01 100644 --- a/lib/ExtUtils/Installed.pm +++ b/lib/ExtUtils/Installed.pm @@ -1,6 +1,6 @@ package ExtUtils::Installed; -use 5.6.1; +use 5.006_001; use strict; use Carp qw(); use ExtUtils::Packlist; diff --git a/lib/ExtUtils/Liblist.pm b/lib/ExtUtils/Liblist.pm index ae565fc..09421e3 100644 --- a/lib/ExtUtils/Liblist.pm +++ b/lib/ExtUtils/Liblist.pm @@ -21,7 +21,7 @@ package ExtUtils::Liblist::Kid; # This kid package is to be used by MakeMaker. It will not work if # $self is not a Makemaker. -use 5.6.1; +use 5.006_001; # Broken out of MakeMaker from version 4.11 our $VERSION = substr q$Revision: 1.27 $, 10; diff --git a/lib/ExtUtils/Mksymlists.pm b/lib/ExtUtils/Mksymlists.pm index 5861131..0135cda 100644 --- a/lib/ExtUtils/Mksymlists.pm +++ b/lib/ExtUtils/Mksymlists.pm @@ -1,6 +1,6 @@ package ExtUtils::Mksymlists; -use 5.6.1; +use 5.006_001; use strict qw[ subs refs ]; # no strict 'vars'; # until filehandles are exempted diff --git a/lib/ExtUtils/Packlist.pm b/lib/ExtUtils/Packlist.pm index 7b664d1..ea4ec5e 100644 --- a/lib/ExtUtils/Packlist.pm +++ b/lib/ExtUtils/Packlist.pm @@ -1,6 +1,6 @@ package ExtUtils::Packlist; -use 5.6.1; +use 5.006_001; use strict; use Carp qw(); our $VERSION = '0.04'; diff --git a/lib/Fatal.pm b/lib/Fatal.pm index bf54d91..0ea5963 100644 --- a/lib/Fatal.pm +++ b/lib/Fatal.pm @@ -1,6 +1,6 @@ package Fatal; -use 5.6.1; +use 5.006_001; use Carp; use strict; our($AUTOLOAD, $Debug, $VERSION); diff --git a/lib/File/Basename.pm b/lib/File/Basename.pm index e16f871..c765788 100644 --- a/lib/File/Basename.pm +++ b/lib/File/Basename.pm @@ -135,7 +135,7 @@ BEGIN { -use 5.6.0; +use 5.006; use warnings; our(@ISA, @EXPORT, $VERSION, $Fileparse_fstype, $Fileparse_igncase); require Exporter; diff --git a/lib/File/CheckTree.pm b/lib/File/CheckTree.pm index 35f7906..e58e3ec 100644 --- a/lib/File/CheckTree.pm +++ b/lib/File/CheckTree.pm @@ -2,7 +2,7 @@ package File::CheckTree; our $VERSION = '4.1'; -require 5.6.0; +use 5.006; require Exporter; use warnings; diff --git a/lib/File/Compare.pm b/lib/File/Compare.pm index b83ba62..e1d5e7d 100644 --- a/lib/File/Compare.pm +++ b/lib/File/Compare.pm @@ -1,6 +1,6 @@ package File::Compare; -use 5.6.0; +use 5.006; use strict; use warnings; our($VERSION, @ISA, @EXPORT, @EXPORT_OK, $Too_Big); diff --git a/lib/File/Copy.pm b/lib/File/Copy.pm index 7daa3ed..afb7635 100644 --- a/lib/File/Copy.pm +++ b/lib/File/Copy.pm @@ -7,7 +7,7 @@ package File::Copy; -use 5.6.0; +use 5.006; use strict; use warnings; use Carp; diff --git a/lib/File/Find.pm b/lib/File/Find.pm index 1ebfba3..de0b534 100644 --- a/lib/File/Find.pm +++ b/lib/File/Find.pm @@ -1,7 +1,7 @@ package File::Find; +use 5.006; use strict; use warnings; -use 5.6.0; our $VERSION = '1.02'; require Exporter; require Cwd; diff --git a/lib/File/Path.pm b/lib/File/Path.pm index 7d56d48..3560a97 100644 --- a/lib/File/Path.pm +++ b/lib/File/Path.pm @@ -91,7 +91,7 @@ Charles Bailey > =cut -use 5.6.0; +use 5.006; use Carp; use File::Basename (); use Exporter (); diff --git a/lib/File/stat.pm b/lib/File/stat.pm index aff5d03..accae9f 100644 --- a/lib/File/stat.pm +++ b/lib/File/stat.pm @@ -1,8 +1,9 @@ package File::stat; +use 5.006; + use strict; use warnings; -use 5.6.0; our(@EXPORT, @EXPORT_OK, %EXPORT_TAGS); our $VERSION = '1.00'; diff --git a/lib/FileHandle.pm b/lib/FileHandle.pm index 51c73be..6be2242 100644 --- a/lib/FileHandle.pm +++ b/lib/FileHandle.pm @@ -1,6 +1,6 @@ package FileHandle; -use 5.6.1; +use 5.006; use strict; our($VERSION, @ISA, @EXPORT, @EXPORT_OK); diff --git a/lib/Math/Trig.pm b/lib/Math/Trig.pm index e4732c1..d1ac4f5 100644 --- a/lib/Math/Trig.pm +++ b/lib/Math/Trig.pm @@ -7,7 +7,7 @@ require Exporter; package Math::Trig; -use 5.6.1; +use 5.006; use strict; use Math::Complex qw(:trig); diff --git a/lib/Net/Ping.pm b/lib/Net/Ping.pm index 8226a97..c963a07 100644 --- a/lib/Net/Ping.pm +++ b/lib/Net/Ping.pm @@ -12,7 +12,7 @@ package Net::Ping; # Copyright (c) 2001, Colin McMillen. All rights reserved. This # program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. -use 5.6.1; +use 5.006_001; require Exporter; use strict; diff --git a/lib/Net/hostent.pm b/lib/Net/hostent.pm index 44537a2..04cbee3 100644 --- a/lib/Net/hostent.pm +++ b/lib/Net/hostent.pm @@ -1,7 +1,7 @@ package Net::hostent; use strict; -use 5.6.1; +use 5.006_001; our $VERSION = '1.00'; our(@EXPORT, @EXPORT_OK, %EXPORT_TAGS); BEGIN { diff --git a/lib/Net/netent.pm b/lib/Net/netent.pm index 210da62..f7d32cb 100644 --- a/lib/Net/netent.pm +++ b/lib/Net/netent.pm @@ -1,7 +1,7 @@ package Net::netent; use strict; -use 5.6.1; +use 5.006_001; our $VERSION = '1.00'; our(@EXPORT, @EXPORT_OK, %EXPORT_TAGS); BEGIN { diff --git a/lib/Net/protoent.pm b/lib/Net/protoent.pm index 5bd0b83..2cbccad 100644 --- a/lib/Net/protoent.pm +++ b/lib/Net/protoent.pm @@ -1,7 +1,7 @@ package Net::protoent; use strict; -use 5.6.1; +use 5.006_001; our $VERSION = '1.00'; our(@EXPORT, @EXPORT_OK, %EXPORT_TAGS); BEGIN { diff --git a/lib/Net/servent.pm b/lib/Net/servent.pm index eaf621a..63ae307 100644 --- a/lib/Net/servent.pm +++ b/lib/Net/servent.pm @@ -1,7 +1,7 @@ package Net::servent; use strict; -use 5.6.1; +use 5.006_001; our $VERSION = '1.00'; our(@EXPORT, @EXPORT_OK, %EXPORT_TAGS); BEGIN { diff --git a/lib/Shell.pm b/lib/Shell.pm index 5d2f217..9762a3a 100644 --- a/lib/Shell.pm +++ b/lib/Shell.pm @@ -1,5 +1,5 @@ package Shell; -use 5.6.1; +use 5.006_001; use strict; use warnings; our($capture_stderr, $VERSION, $AUTOLOAD); diff --git a/lib/Tie/Array.pm b/lib/Tie/Array.pm index c751d5b..1cc99b8 100644 --- a/lib/Tie/Array.pm +++ b/lib/Tie/Array.pm @@ -1,6 +1,6 @@ package Tie::Array; -use 5.6.1; +use 5.006_001; use strict; use Carp; our $VERSION = '1.02'; diff --git a/lib/Tie/Handle.pm b/lib/Tie/Handle.pm index 8e40589..6fd30d8 100644 --- a/lib/Tie/Handle.pm +++ b/lib/Tie/Handle.pm @@ -1,6 +1,6 @@ package Tie::Handle; -use 5.6.1; +use 5.006_001; our $VERSION = '4.1'; =head1 NAME diff --git a/lib/Time/Local.pm b/lib/Time/Local.pm index 6180584..e99aab1 100644 --- a/lib/Time/Local.pm +++ b/lib/Time/Local.pm @@ -1,5 +1,5 @@ package Time::Local; -require 5.6.0; +use 5.006; require Exporter; use Carp; use strict; diff --git a/lib/Time/gmtime.pm b/lib/Time/gmtime.pm index 39cfdc2..4e1359b 100644 --- a/lib/Time/gmtime.pm +++ b/lib/Time/gmtime.pm @@ -1,8 +1,9 @@ package Time::gmtime; use strict; +use 5.006_001; + use Time::tm; -use 5.6.1; our(@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION); BEGIN { use Exporter (); diff --git a/lib/Time/localtime.pm b/lib/Time/localtime.pm index 5495559..c3d9fb3 100644 --- a/lib/Time/localtime.pm +++ b/lib/Time/localtime.pm @@ -1,8 +1,9 @@ package Time::localtime; use strict; +use 5.006_001; + use Time::tm; -use 5.6.1; our(@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION); BEGIN { use Exporter (); diff --git a/lib/User/grent.pm b/lib/User/grent.pm index e146ec0..d9581d8 100644 --- a/lib/User/grent.pm +++ b/lib/User/grent.pm @@ -1,7 +1,7 @@ package User::grent; use strict; -use 5.6.1; +use 5.006_001; our $VERSION = '1.00'; our(@EXPORT, @EXPORT_OK, %EXPORT_TAGS); BEGIN { diff --git a/lib/base.pm b/lib/base.pm index 00391b4..c6d8cca 100644 --- a/lib/base.pm +++ b/lib/base.pm @@ -44,7 +44,7 @@ L package base; -use 5.6.1; +use 5.006_001; our $VERSION = "1.02"; sub import { diff --git a/lib/diagnostics.pm b/lib/diagnostics.pm index 5d8f4e7..031b08e 100755 --- a/lib/diagnostics.pm +++ b/lib/diagnostics.pm @@ -168,7 +168,7 @@ Tom Christiansen >, 25 June 1995. =cut use strict; -use 5.6.0; +use 5.006; use Carp; our $VERSION = 1.1; diff --git a/lib/fields.pm b/lib/fields.pm index 5374848..be2a7ae 100644 --- a/lib/fields.pm +++ b/lib/fields.pm @@ -127,7 +127,7 @@ L =cut -use 5.6.1; +use 5.006_001; use strict; no strict 'refs'; use warnings::register; diff --git a/lib/vars.pm b/lib/vars.pm index 4abc2d1..a051ba1 100644 --- a/lib/vars.pm +++ b/lib/vars.pm @@ -1,6 +1,6 @@ package vars; -require 5.6.0; +use 5.006; our $VERSION = '1.01'; diff --git a/pod/perl56delta.pod b/pod/perl56delta.pod index fc0d668..75d7728 100644 --- a/pod/perl56delta.pod +++ b/pod/perl56delta.pod @@ -112,16 +112,14 @@ to check if you're running a particular version of Perl: # new features supported } -C and C also have some special magic to support such literals. -They will be interpreted as a version rather than as a module name: - - require v5.6.0; # croak if $^V lt v5.6.0 - use v5.6.0; # same, but croaks at compile-time - -Alternatively, the C may be omitted if there is more than one dot: - - require 5.6.0; - use 5.6.0; +C and C also have some special magic to support such +literals, but this particular usage should be avoided because it leads to +misleading error messages under versions of Perl which don't support vector +strings. Using a true version number will ensure correct behavior in all +versions of Perl: + + require 5.006; # run time check for v5.6 + use 5.006_001; # compile time check for v5.6.1 Also, C and C support the Perl-specific format flag C<%v> to print ordinals of characters in arbitrary strings: diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 0761412..2c198c1 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -3755,19 +3755,23 @@ rename(2) manpage or equivalent system documentation for details. =item require -Demands some semantics specified by EXPR, or by C<$_> if EXPR is not -supplied. +Demands a version of Perl specified by VERSION, or demands some semantics +specified by EXPR or by C<$_> if EXPR is not supplied. -If a VERSION is specified as a literal of the form v5.6.1, -demands that the current version of Perl (C<$^V> or $PERL_VERSION) be -at least as recent as that version, at run time. (For compatibility -with older versions of Perl, a numeric argument will also be interpreted -as VERSION.) Compare with L, which can do a similar check at -compile time. +VERSION may be either a numeric argument such as 5.006, which will be +compared to C<$]>, or a literal of the form v5.6.1, which will be compared +to C<$^V> (aka $PERL_VERSION). A fatal error is produced at run time if +VERSION is greater than the version of the current Perl interpreter. +Compare with L, which can do a similar check at compile time. + +Specifying VERSION as a literal of the form v5.6.1 should generally be +avoided, because it leads to misleading error messages under earlier +versions of Perl which do not support this syntax. The equivalent numeric +version should be used instead. require v5.6.1; # run time version check require 5.6.1; # ditto - require 5.005_03; # float version allowed for compatibility + require 5.006_001; # ditto; preferred for backwards compatibility Otherwise, demands that a library file be included if it hasn't already been included. The file is included via the do-FILE mechanism, which is @@ -5640,18 +5644,21 @@ package. It is exactly equivalent to except that Module I be a bareword. -VERSION, which can be specified as a literal of the form v5.6.1, demands -that the current version of Perl (C<$^V> or $PERL_VERSION) be at least -as recent as that version. (For compatibility with older versions of Perl, -a numeric literal will also be interpreted as VERSION.) If the version -of the running Perl interpreter is less than VERSION, then an error -message is printed and Perl exits immediately without attempting to -parse the rest of the file. Compare with L, which can do a -similar check at run time. +VERSION may be either a numeric argument such as 5.006, which will be +compared to C<$]>, or a literal of the form v5.6.1, which will be compared +to C<$^V> (aka $PERL_VERSION. A fatal error is produced if VERSION is +greater than the version of the current Perl interpreter; Perl will not +attempt to parse the rest of the file. Compare with L, which can +do a similar check at run time. + +Specifying VERSION as a literal of the form v5.6.1 should generally be +avoided, because it leads to misleading error messages under earlier +versions of Perl which do not support this syntax. The equivalent numeric +version should be used instead. use v5.6.1; # compile time version check use 5.6.1; # ditto - use 5.005_03; # float version allowed for compatibility + use 5.006_001; # ditto; preferred for backwards compatibility This is often useful if you need to check the current Perl version before Cing library modules that have changed in incompatible ways from diff --git a/pp_ctl.c b/pp_ctl.c index 0b7daa1..5d2d10f 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -3078,7 +3078,7 @@ PP(pp_require) if (sver == 0 && (rev > 5 || (rev == 5 && ver >= 100))) { DIE(aTHX_ "Perl v%"UVuf".%"UVuf".%"UVuf" required--" "this is only v%d.%d.%d, stopped" - " (did you mean v%"UVuf".%"UVuf".0?)", + " (did you mean v%"UVuf".%03"UVuf"?)", rev, ver, sver, PERL_REVISION, PERL_VERSION, PERL_SUBVERSION, rev, ver/100); } diff --git a/utils/pl2pm.PL b/utils/pl2pm.PL index 5637818..d135bc8 100644 --- a/utils/pl2pm.PL +++ b/utils/pl2pm.PL @@ -129,7 +129,7 @@ while (<>) { if ( open(PM, ">$newname") ) { print PM <<"END"; package $newpack; -require 5.6.0; +use 5.006; require Exporter; $carp \@ISA = qw(Exporter);