t/op/universal.t See if UNIVERSAL class works
t/op/unshift.t See if unshift works
t/op/vec.t See if vectors work
-t/op/ver.t See if version tuples work
+t/op/ver.t See if v-strings and the %v format flag work
t/op/wantarray.t See if wantarray works
t/op/write.t See if write works
t/pod/emptycmd.t Test empty pod directives
*EGID
*PROGRAM_NAME
*PERL_VERSION
- *PERL_VERSION_TUPLE
*ACCUMULATOR
*DEBUGGING
*SYSTEM_FD_MAX
# Internals.
- *PERL_VERSION = *] ;
- *PERL_VERSION_TUPLE = *^V ;
+ *PERL_VERSION = *^V ;
*ACCUMULATOR = *^A ;
*COMPILING = *^C ;
*DEBUGGING = *^D ;
# *ARRAY_BASE = *[ ;
# *OFMT = *# ;
# *MULTILINE_MATCHING = ** ;
+# *OLD_PERL_VERSION = *] ;
1;
if (version != Nullop) {
SV *vesv = ((SVOP*)version)->op_sv;
- if (arg == Nullop && !SvNIOK(vesv)) {
+ if (arg == Nullop && !SvNIOKp(vesv)) {
arg = version;
}
else {
OP *pack;
SV *meth;
- if (version->op_type != OP_CONST || !SvNIOK(vesv))
+ if (version->op_type != OP_CONST || !SvNIOKp(vesv))
Perl_croak(aTHX_ "Version number must be constant number");
/* Make copy of id so we don't free it twice */
/* Fake up an import/unimport */
if (arg && arg->op_type == OP_STUB)
imop = arg; /* no import on explicit () */
- else if (SvNIOK(((SVOP*)id)->op_sv)) {
+ else if (SvNIOKp(((SVOP*)id)->op_sv)) {
imop = Nullop; /* use 5.0; */
}
else {
See L<perldata>.
+=head2 Perl's version numbering has changed
+
+Beginning with Perl version 5.6, the version number convention has been
+changed to a "dotted integer" scheme that is more commonly found in open
+source projects.
+
+Maintenance versions of v5.6.0 will be released as v5.6.1, v5.6.2 etc.
+The next development series following v5.6 will be numbered v5.7.x,
+beginning with v5.7.0, and the next major production release following
+v5.6 will be v5.8.
+
+The English module now sets $PERL_VERSION to $^V (a string value) rather
+than C<$]> (a numeric value). (This is a potential incompatibility.
+Send us a report via perlbug if you are affected by this.)
+
+The v1.2.3 syntax is also now legal in Perl.
+See L<Support for strings represented as a vector of ordinals> for more on that.
+
+To cope with the new versioning system's use of at least three significant
+digits for each version component, the method used for incrementing the
+subversion number has also changed slightly. We assume that versions older
+than v5.6 have been incrementing the subversion component in multiples of
+10. Versions after v5.6.0 will increment them by 1. Thus, using the new
+notation, 5.005_03 is the same as v5.5.30, and the first maintenance
+version following v5.6.0 will be v5.6.1, which amounts to a floating point
+value of 5.006_001).
+
=item Possibly changed pseudo-random number generator
In 5.005_0x and earlier, perl's rand() function used the C library
interpreter threads). C<use Thread;> continues to be available when you
ask for -Duse5005threads, bugs and all.
-=head2 Perl's version numbering has changed
-
-Beginning with Perl version 5.6, the version number convention has been
-changed to a "dotted tuple" scheme that is more commonly found in open
-source projects.
-
-Maintenance versions of v5.6.0 will be released as v5.6.1, v5.6.2 etc.
-The next development series following v5.6 will be numbered v5.7.x,
-beginning with v5.7.0, and the next major production release following
-v5.6 will be v5.8.
-
-The v1.2.3 syntax is also now legal in Perl. See L<Support for version tuples>
-for more on that.
-
-To cope with the new versioning system's use of at least three significant
-digits for each version component, the method used for incrementing the
-subversion number has also changed slightly. We assume that versions older
-than v5.6 have been incrementing the subversion component in multiples of
-10. Versions after v5.6 will increment them by 1. Thus, using the new
-notation, 5.005_03 is the same as v5.5.30, and the first maintenance
-version following v5.6 will be v5.6.1, which amounts to a floating point
-value of 5.006_001).
-
=head2 New Configure flags
The following new flags may be enabled on the Configure command line
the opportunity to introduce typing and other attributes for such
variables. See L<perlfunc/our>.
-=head2 Support for version tuples
+=head2 Support for strings represented as a vector of ordinals
-Literals of the form v1.2.3.4 are now parsed as the utf8 string
-C<"\x{1}\x{2}\x{3}\x{4}">. This allows comparing version numbers using
-regular string comparison operators C<eq>, C<ne>, C<lt>, C<gt> etc.
+Literals of the form v1.2.3.4 are now parsed as a string comprised of
+of characters with the specified ordinals. This is an alternative, more
+readable way to construct (possibly unicode) strings instead of
+interpolating characters, as in C<"\x{1}\x{2}\x{3}\x{4}">.
-These "dotted tuples" are dual-valued. They are both strings of utf8
-characters, and floating point numbers. Thus v1.2.3.4 has the string
-value C<"\x{1}\x{2}\x{3}\x{4}"> and the numeric value 1.002_003_004.
-As another example, v5.5.640 has the string value C<"\x{5}\x{5}\x{280}">
-(remember 280 hexadecimal is 640 decimal) and the numeric value
-5.005_64.
+Strings written in this form are also useful to represent version "numbers".
+It is easy to compare such version "numbers" (which are really just plain
+strings) using any of the usual string comparison operators C<eq>, C<ne>,
+C<lt>, C<gt>, etc., or perform bitwise string operations on them using C<|>,
+C<&>, etc.
In conjunction with the new C<$^V> magic variable (which contains
-the perl version in this format), such literals can be used to
-check if you're running a particular version of Perl.
+the perl version as a string), such literals can be used as a readable way
+to check if you're running a particular version of Perl:
+ # this will parse in older versions of Perl also
if ($^V and $^V gt v5.5.640) {
- # new style version numbers are supported
+ # new features supported
}
-C<require> and C<use> also support such literals:
+C<require> and C<use> 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
-C<sprintf> and C<printf> support the Perl-specific format flag C<%v>
+Also, C<sprintf> and C<printf> support the Perl-specific format flag C<%v>
to print ordinals of characters in arbitrary strings:
printf "v%vd", $^V; # prints current version, such as "v5.5.650"
printf "%*vX", ":", $addr; # formats IPv6 address
printf "%*vb", "", $bits; # displays bitstring as contiguous 0's and 1's
+See L<perlop/"Strings of Character"> for additional information.
+
=head2 Weak references
WARNING: This is an experimental feature.
=head2 New variable $^V contains Perl version in v5.6.0 format
-C<$^V> contains the Perl version number as a version tuple that
-can be used in string or numeric comparisons. See
-C<Support for version tuples> for an example.
+C<$^V> contains the Perl version number as a string comprised of
+characters whose ordinals match the version numbers, so that it may
+be used in string comparisons.
+
+See C<Support for strings represented as a vector of ordinals> for an
+example.
=head2 Optional Y2K warnings
The Devel::Peek module provides access to the internal representation
of Perl variables and data. It is a data debugging tool for the XS programmer.
+=item English
+
+$PERL_VERSION now stands for C<$^V> (a string value) rather than for C<$]>
+(a numeric value).
+
=item ExtUtils::MakeMaker
change#4135, also needs docs in module pod
=item require
Demands some semantics specified by EXPR, or by C<$_> if EXPR is not
-supplied. If a version number or tuple is specified, or if EXPR is
-numeric, demands that the current version of Perl
-(C<$^V> or C<$]> or $PERL_VERSION) be equal or greater than EXPR.
+supplied.
+
+If a VERSION is specified as a literal of the form v5.6.0,
+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</use>, which can do a similar check at
+compile time.
+
+ require v5.6.0; # run time version check
+ require 5.005_03; # same, number still supported for 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
except that Module I<must> be a bareword.
-If the first argument to C<use> is a number or a version tuple, it is
-treated as a version instead of a module name. If the version
-of the Perl interpreter is less than VERSION, then an error message
-is printed and Perl exits immediately.
+VERSION, which can be specified as a literal of the form v5.6.0, 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</require>, which can do a
+similar check at run time.
- use 5.005_03; # version number
- use v5.6.0; # version tuple
+ use v5.6.0; # compile time version check
+ use 5.005_03; # same, number still supported for compatibility
This is often useful if you need to check the current Perl version before
C<use>ing library modules that have changed in incompatible ways from
If the VERSION argument is present between Module and LIST, then the
C<use> will call the VERSION method in class Module with the given
version as an argument. The default VERSION method, inherited from
-the Universal class, croaks if the given version is larger than the
+the UNIVERSAL class, croaks if the given version is larger than the
value of the variable C<$Module::VERSION>.
Again, there is a distinction between omitting LIST (C<import> called
See L<perlfunc/vec> for information on how to manipulate individual bits
in a bit vector.
-=head2 Version tuples
-
-A literal of the form C<v1.20.300.4000> is parsed as a dual-valued quantity.
-It has the string value of C<"\x{1}\x{14}\x{12c}\x{fa0}"> (i.e., a UTF-8
-string) and a numeric value of C<1 + 20/1000 + 300/1000000 + 4000/1000000000>.
-This is useful for representing Unicode strings, and for comparing version
-numbers using the string comparison operators, C<cmp>, C<gt>, C<lt> etc.
-
-Such "version tuples" or "vectors" are accepted by both C<require> and
-C<use>. The C<$^V> variable contains the running Perl interpreter's
-version in this format. See L<perlvar/$^V>.
+=head2 Strings of Character
+
+A literal of the form C<v1.20.300.4000> is parsed as a string comprised
+of characters with the specified ordinals. This provides an alternative,
+more readable way to construct strings, rather than use the somewhat less
+readable interpolation form C<"\x{1}\x{14}\x{12c}\x{fa0}">. This is useful
+for representing Unicode strings, and for comparing version "numbers"
+using the string comparison operators, C<cmp>, C<gt>, C<lt> etc.
+
+Such literals are accepted by both C<require> and C<use> for doing a version
+check. The C<$^V> special variable also contains the running Perl
+interpreter's version in this form. See L<perlvar/$^V>.
=head2 Integer Arithmetic
directive, and cannot influence the behavior of any other file.
Its use is highly discouraged.
-=item $PERL_VERSION
-
=item $]
The version + patchlevel / 1000 of the Perl interpreter. This variable
See also the documentation of C<use VERSION> and C<require VERSION>
for a convenient way to fail if the running Perl interpreter is too old.
-See C<$^V> for a more modern representation of the Perl version.
+The use of this variable is deprecated. The floating point representation
+can sometimes lead to inaccurate numeric comparisons. See C<$^V> for a
+more modern representation of the Perl version that allows accurate string
+comparisons.
=item $COMPILING
epoch (beginning of 1970). The values returned by the B<-M>, B<-A>,
and B<-C> filetests are based on this value.
-=item $PERL_VERSION_TUPLE
+=item $PERL_VERSION
=item $^V
The revision, version, and subversion of the Perl interpreter, represented
-as a "version tuple". Version tuples have both a numeric value and a
-string value. The numeric value is a floating point number that amounts
-to revision + version/1000 + subversion/1000000, and the string value
-is made of characters possibly in the UTF-8 range:
-C<chr($revision) . chr($version) . chr($subversion)>.
+as a string comprised of characters with those ordinals. Thus in Perl v5.6.0
+it equals C<chr(5) . chr(6) . chr(0)> and will return true for
+C<$^V eq v5.6.0>. Note that the characters in this string value can
+potentially be in Unicode range.
This can be used to determine whether the Perl interpreter executing a
script is in the right range of versions. (Mnemonic: use ^V for Version
-control.) Example:
+Control.) Example:
- warn "No "our" declarations!\n" if $^V and $^V lt v5.6;
+ warn "No "our" declarations!\n" if $^V and $^V lt v5.6.0;
-See also the documentation of C<use VERSION> and C<require VERSION>
+See the documentation of C<use VERSION> and C<require VERSION>
for a convenient way to fail if the running Perl interpreter is too old.
See also C<$]> for an older representation of the Perl version.
# don't make this lexical
$i = 1;
-print "1..20\n";
+print "1..18\n";
sub do_require {
%INC = ();
print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.2 required/;
print "ok ",$i++,"\n";
-my $ver = v5.5.630;
+my $ver = 5.005_63;
eval { require $ver; };
print "# $@\nnot " if $@;
print "ok ",$i++,"\n";
-$ver = v10.0.2;
+# check inaccurate fp
+#$ver = 10.2;
+#eval { require $ver; };
+#print "# $@\nnot " unless $@ =~ /^Perl v10\.200\.0 required/;
+#print "ok ",$i++,"\n";
+
+$ver = 10.000_02;
eval { require $ver; };
-print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.2 required/;
+print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.20 required/;
print "ok ",$i++,"\n";
print "not " unless v5.5.1 gt v5.5;
print "ok ",$i++,"\n";
-print "not " unless 5.005_01 > v5.5;
-print "ok ",$i++,"\n";
-
-print "not " unless 5.005_64 - v5.5.640 < 0.0000001;
-print "ok ",$i++,"\n";
-
{
use utf8;
print "not " unless v5.5.640 eq "\x{5}\x{5}\x{280}";
unshift @INC, "../lib";
}
-print "1..15\n";
+print "1..14\n";
my $test = 1;
print "not " unless v1.20.300.4000 eq "\x{1}\x{14}\x{12c}\x{fa0}";
print "ok $test\n"; ++$test;
-print "not " unless v1.20.300.4000 > 1.0203039 and v1.20.300.4000 < 1.0203041;
-print "ok $test\n"; ++$test;
-
print "not " unless sprintf("%vd", "Perl") eq '80.101.114.108';
print "ok $test\n"; ++$test;
S_force_version(pTHX_ char *s)
{
OP *version = Nullop;
+ bool is_vstr = FALSE;
+ char *d;
s = skipspace(s);
- if (isDIGIT(*s) || (*s == 'v' && isDIGIT(s[1]))) {
- char *d = s;
- if (*d == 'v')
- d++;
+ d = s;
+ if (*d == 'v') {
+ is_vstr = TRUE;
+ d++;
+ }
+ if (isDIGIT(*d)) {
for (; isDIGIT(*d) || *d == '_' || *d == '.'; d++);
if (*d == ';' || isSPACE(*d) || *d == '}' || !*d) {
s = scan_num(s);
/* real VERSION number -- GBARR */
version = yylval.opval;
+ if (is_vstr) {
+ SV *ver = cSVOPx(version)->op_sv;
+ SvUPGRADE(ver, SVt_PVIV);
+ SvIOKp_on(ver); /* hint that it is a version */
+ }
}
}
UV rev;
U8 tmpbuf[UTF8_MAXLEN];
U8 *tmpend;
- NV nshift = 1.0;
bool utf8 = FALSE;
s++; /* get past 'v' */
sv = NEWSV(92,5);
- SvUPGRADE(sv, SVt_PVNV);
sv_setpvn(sv, "", 0);
do {
tmpend = &tmpbuf[1];
}
sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf);
- if (rev > 0)
- SvNVX(sv) += (NV)rev/nshift;
- nshift *= 1000;
} while (*pos == '.' && isDIGIT(pos[1]));
if (*s == '0' && isDIGIT(s[1]))
tmpend = uv_to_utf8(tmpbuf, rev);
utf8 = utf8 || rev > 127;
sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf);
- if (rev > 0)
- SvNVX(sv) += (NV)rev/nshift;
SvPOK_on(sv);
- SvNOK_on(sv);
SvREADONLY_on(sv);
if (utf8) {
SvUTF8_on(sv);