[perl #43022] Change of behavior between 5.6.0 and 5.8.0
by Mark-Jason Dominus other posts by this author
May 22 2007 8:36AM messages near this date
[perl #43023] Failure in perl 5.8.5 installation in linux7.2 - Please help
|
Re: [perl #43022] Change of behavior between 5.6.0 and 5.8.0
# New Ticket Created by Mark-Jason Dominus
# Please include the string: [perl #43022]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=43022 >
This is a bug report for perl from mjd@[...].com,
generated with the help of perlbug 1.34 running under perl v5.8.0.
-----------------------------------------------------------------
[Please enter your report here]
I haven't looked into this at all, and the test case I am providing is
very bad, in the sense that I have not tried to trim it down. I wrote
the attached code around ten years ago, and was surprised to discover
that it no longer works.
This may be a documented changed; I don't know. As I said, I have not
investigated this.
The output from the enclosed "demo.pl" file should be:
IX + IX = 18
XI * IV = 44
II ** X = 1024
M - I = 999
Powers of II:
1
2
4
8
16
32
64
128
With 5.6.0, that is indeed the output. With 5.8.0, the output is
erroneous:
IX + IX = 0
XI * IV = 0
II ** X = 1
M - I = 0
Powers of II:
Here between lines with ========= is demo.pl:
========
#!/usr/bin/perl
use Roman;
print "IX + IX = ", $IX + $IX, "\n";
print "XI * IV = ", $XI * $IV, "\n";
print "II ** X = ", $II ** $X, "\n";
print "M - I = ", $M-$I, "\n";
print "Powers of II:\n";
for ($p = $I; $p < $CLVI; $p *= $II) {
print "\t", $p, "\n";
}
========
Here is the required Roman.pm:
========
package Roman;
my %val = (
'M' => 1000,
'CM' => 900,
'D' => 500,
'CD' => 400,
'C' => 100,
'XC' => 90,
'L' => 50,
'XL' => 40,
'X' => 10,
'IX' => 9,
'V' => 5,
'IV' => 4,
'I' => 1,
);
my %rom = reverse %val;
my $rpat = join '|', sort {$val{$b} <=> $val{$a}} keys %val;
my @vals = sort {$b <=> $a} values %val;
sub import {
my $pack = shift;
my $caller = caller;
my %args = @_;
my $top = $args{Top} || 3999;
my $i;
for ($i=1; $i<= $top; $i++) {
my $name = $caller . '::' . i2r($i);
my $var;
tie $var, $pack, $i;
*{$name} = \$var;
}
}
sub new {
&TIESCALAR;
}
sub TIESCALAR {
my $pack = shift;
my $v = shift;
bless \$v => $pack;
}
sub FETCH {
my $self = shift;
$$self;
}
sub r2i {
my $r = shift;
my $i = 0;
while ($r =~ /\G($rpat)/og) {
$i += $val{$1};
}
$i;
}
sub i2r {
use Carp;
my $i = shift;
my $r = '';
foreach $v (@vals) {
while ($v <= $i) {
$i -= $v;
$r .= $rom{$v};
return $r if $i ==0;
}
}
croak "Can't convert number $i to Roman numeral";
}
sub stringize {
my $self = shift;
my $i = $$self;
i2r($i);
}
sub STORE {
use Carp;
my $self = shift;
my $val = $$self;
my $rom = i2r($val);
carp "Warning; Tried to modify the value of Roman numeral $rom";
my $new = shift;
$new;
}
========
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=low
---
Site configuration information for perl v5.8.0:
Configured by mjd at Thu Apr 17 11:57:37 EDT 2003.
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.2-2, archname=i586-linux
uname='linux plover.com 2.4.2-2 #1 sun apr 8 19:37:14 edt 2001 i586 unknown '
config_args='-des'
hint=previous, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE
_OFFSET_BITS=64 -I/usr/include/gdbm',
optimize='-O2',
cppflags='-fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm -fno-strict-alia
sing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -fn
o-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/inc
lude/gdbm'
ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1 2.96-81)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldl -lm -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
libc=/lib/libc-2.2.2.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.2.4'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Locally applied patches:
---
@INC for perl v5.8.0:
/usr/local/lib/perl5/5.8.0/i586-linux
/usr/local/lib/perl5/5.8.0
/usr/local/lib/perl5/site_perl/5.8.0/i586-linux
/usr/local/lib/perl5/site_perl/5.8.0
/usr/local/lib/perl5/site_perl/5.7.3
/usr/local/lib/perl5/site_perl/5.7.2
/usr/local/lib/perl5/site_perl/5.6.1
/usr/local/lib/perl5/site_perl/5.6.0
/usr/local/lib/perl5/site_perl
.
---
Environment for perl v5.8.0:
HOME=/home/mjd
LANG=C
LANGUAGE (unset)
LD_LIBRARY_PATH=/lib:/usr/lib:/usr/X11R6/lib
LOGDIR (unset)
PATH=/home/mjd/bin:/home/mjd/misc/blog/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/
usr/games:/sbin:/usr/sbin:/usr/local/bin/X11R6:/usr/local/bin/mh:/data/mysql/bin:/usr/local/
bin/pbm:/usr/local/bin/ezmlm:/home/mjd/TPI/bin:/usr/local/teTeX/bin:/usr/local/mysql/bin
PERL_BADLANG (unset)
SHELL=/bin/bash
Thread:
Mark-Jason Dominus
David Nicol
Jesse Vincent
|