It's going to be tough to reproduce without a testcase. If you can, it
would be good to start stripping things out of you app until you can't
reproduce the problem any more.
Yeah, I think you missed the top part of that post, with a
test case ;-)
perlbug is correct, but without a test case it's rather unlikely anyone
can do anything about it. (It is, of course, possible someone on p5p
will spot something I haven't.)
Here's a draft of what I plan to submit via perlbug including
the test case:
This is a bug report for perl from (e-mail address removed),
Operating System: 64-bit Windows 7.
Perl Version: ActivePerl version 5.12.1.1201 64-bit:
---
Flags:
category=core
severity=high
---
Code to reproduce this problem:
#====================================================
@Big1 = ();
$Big1[4] = 0;
$Big1[9] = 1;
$Big1[6] = 2;
my $len = 0; # This appears to be significant
foreach $key (@Big1) {
$len = length ($key);
print "key = $key, len=$len\n";
}
exit;
#=====================================================
Using ActivePerl version 5.12.1.1201 64-bit I get:
C:\ZIP>c:\perl512\bin\perl.exe test.pl
key = , len=0
key = , len=0
key = , len=0
key = , len=0
key = 0, len=1
key = , len=1 <==== ???
key = 2, len=1
key = , len=1 <==== ???
key = , len=1 <==== ???
key = 1, len=1
Using ActivePerl version 5.10.1.1007 64-bit I get:
C:\ZIP>C:\perl510\bin\perl.exe test.pl
key = , len=0
key = , len=0
key = , len=0
key = , len=0
key = 0, len=1
key = , len=0
key = 2, len=1
key = , len=0
key = , len=0
key = 1, len=1
Some other Perl programmers have taken the position that this
is a programmer error because the code attempts to establish
the length() of an undef value. That, they say, is garbage
analogous to division by zero.
I disagree and cite the following in support of my position
that this constitutes a bug:
1. Perl Version 5.10.1.1007 and every other major Perl version
going back 10 plus years have consistently returned zero
for the length of an undef value.
2. perlsyn clearly states:
"A variable holds the undefined value ("undef") until it has been
assigned a defined value, which is anything other than "undef".
When used as a number, "undef" is treated as 0; when used as a
string, it is treated as the empty string, ""; and when used as
a reference that isn't being assigned to, it is treated as an error."
Thus "undef" should be treated as the empty string. And the
length of the empty string is unambiguously zero. Hence the
behaviour of the 5.12.1.1201 is clearly a bug!
Summary of my perl5 (revision 5 version 12 subversion 1) configuration:
[snip]
--
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Malcolm Hoar "The more I practice, the luckier I get". |
| (e-mail address removed) Gary Player. |
|
http://www.malch.com/ Shpx gur PQN. |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~