Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.91k stars 542 forks source link

$] prints 5.006 not 5.6 #3428

Closed p5pRT closed 20 years ago

p5pRT commented 23 years ago

Migrated from rt.perl.org#5836 (status was 'resolved')

Searchable as RT5836$

p5pRT commented 23 years ago

From vicki.brown@barclaysglobal.com

Under Perl 5.6\, the variable $] contains the value 5.006 rather than the expected 5.6. $^V contains 5.6.0.

Before you jump in and tell me that $] is deprecated; it's not\, it's just old\, and it's more portable given that $^V isn't defined in pre-5.6 Perl. So\, if I'm going to do the test of "is this Perl less than Perl 5.6) I need to use $] to do it.

Unfortunately\, 5.006 _is_ lt 5.6!

Code to reproduce​:

  require 5.6.0;

  print "Running Perl version $]\n";   print "Running Perl version ";   printf ("%vd\n"\, $^V); # uninitialized var in 5.004 and 5.00503

  warn "No 'our' declarations!\n" if $^V lt v5.6;   warn "Cannot use our in version $]!\n" if $] \< 5.6;

Output

Running Perl version 5.006 Running Perl version 5.6.0 Cannot use our in version 5.006!

Perl Info ``` Flags: category=core severity=low Site configuration information for perl v5.6.0: Configured by jacobc at Tue Jun 13 16:36:22 PDT 2000. Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration: Platform: osname=solaris, osvers=2.6, archname=sun4-solaris uname='sunos aa-backup1 5.6 generic_105181-15 sun4u sparc sunw,ultra-2 ' config_args='-Dprefix=/usr/local/tools/perl-5.6.0' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef Compiler: cc='cc', optimize='-O', gccversion= cppflags='-I/usr/local/include' ccflags ='-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' stdchar='unsigned char', d_stdstdio=define, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib -L/usr/local/SUNWspro/SC4.2/lib ' libpth=/usr/local/lib /usr/local/SUNWspro/SC4.2/lib /lib /usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldl -lm -lc -lcrypt -lsec libc=, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-KPIC', lddlflags='-G -L/usr/local/lib -L/usr/local/SUNWspro/SC4.2/lib' Locally applied patches: @INC for perl v5.6.0: /usr/local/tools/perl-5.6.0/lib/5.6.0/sun4-solaris /usr/local/tools/perl-5.6.0/lib/5.6.0 /usr/local/tools/perl-5.6.0/lib/site_perl/5.6.0/sun4-solaris /usr/local/tools/perl-5.6.0/lib/site_perl/5.6.0 /usr/local/tools/perl-5.6.0/lib/site_perl . Environment for perl v5.6.0: HOME=/ext203/home/browvic LANG (unset) LANGUAGE (unset) LC_COLLATE=en_US LC_CTYPE=en_US LC_MESSAGES=C LC_MONETARY=en_US LC_NUMERIC=en_US LC_TIME=en_US LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=~/bin/perlbin:/ext203/home/browvic/bin:/ext203/home/browvic/nib:/usr/local/bin:/usr/ucb:/usr/bin:/bin:/etc:/sbin:/usr/sbin:/usr/games:.:/net/asg-sf03/prod/sybase/bin:/usr/lib/lp/postscript:~/Work/bagelbin:~/Work/Bins PERL_BADLANG (unset) SHELL=/bin/tcsh ```
p5pRT commented 23 years ago

From @tamias

On Fri\, Feb 16\, 2001 at 01​:05​:19PM -0800\, vicki.brown@​barclaysglobal.com wrote​:

Under Perl 5.6\, the variable $] contains the value 5.006 rather than the expected 5.6. $^V contains 5.6.0.

That is correct. The numeric version of perl5.6 is 5.006.

Before you jump in and tell me that $] is deprecated; it's not\, it's just old\, and it's more portable given that $^V isn't defined in pre-5.6 Perl. So\, if I'm going to do the test of "is this Perl less than Perl 5.6) I need to use $] to do it.

Unfortunately\, 5.006 _is_ lt 5.6!

Code to reproduce​:

require 5.6.0;

That will not generate the intended behavior in older versions of Perl. (They will complain that the module 5.60 is not found.) Use require 5.006 instead.

print "Running Perl version $]\n"; print "Running Perl version "; printf ("%vd\n"\, $^V); # uninitialized var in 5.004 and 5.00503

warn "No 'our' declarations!\n" if $^V lt v5.6; warn "Cannot use our in version $]!\n" if $] \< 5.6;

That should be​:

warn "Cannot use our in version $]!\n" if $] \< 5.006;

Ronald