P
Paul Lalli
I seem to have found an odd ... well, I don't want to say "bug", because
that would be arrogant of me. Nonetheless, I am thoroughly confused.
Perhaps someone can help explain:
use strict;
use warnings;
my @foo;
$foo[0] = (6..10);
print "Foo: @foo\n";
__END__
This small program returns a warning:
Use of uninitialized value in range (or flip) at - line 4.
And output of:
Foo:
If I switch line four to:
$foo[0] = (6,7,8,9,10);
I get the output I expect (four warnings about using a scalar in void
context, followed by assigning $foo[0] to 10).
This gets more bizzare if I add
use diagnostics;
after use warnings. Rather than pulling the correct warning explanation
from perldiag, the warning disappears altogether.
I have verified this on Perl 5.8.0 on solaris, and 5.8.3 (ActiveState)
on Win2k.
Can someone explain to me what's going on? Why would using a range of
6..10 produce a warning like that, when the expansion does not?
Oh, and just to explain the code - it was written to help explain to
someone a situation in which using @foo[0] instead of $foo[0] would
produce incorrect results, rather than simply a warning message.
Thank you,
Paul Lalli
--
--
Paul Lalli
Senior Software Engineer
ES11 Information Systems
8 Stanley Circle, Suite #8
Latham, NY 12110
p 518-782-1111
f 518-782-1212
e (e-mail address removed)
that would be arrogant of me. Nonetheless, I am thoroughly confused.
Perhaps someone can help explain:
use strict;
use warnings;
my @foo;
$foo[0] = (6..10);
print "Foo: @foo\n";
__END__
This small program returns a warning:
Use of uninitialized value in range (or flip) at - line 4.
And output of:
Foo:
If I switch line four to:
$foo[0] = (6,7,8,9,10);
I get the output I expect (four warnings about using a scalar in void
context, followed by assigning $foo[0] to 10).
This gets more bizzare if I add
use diagnostics;
after use warnings. Rather than pulling the correct warning explanation
from perldiag, the warning disappears altogether.
I have verified this on Perl 5.8.0 on solaris, and 5.8.3 (ActiveState)
on Win2k.
Can someone explain to me what's going on? Why would using a range of
6..10 produce a warning like that, when the expansion does not?
Oh, and just to explain the code - it was written to help explain to
someone a situation in which using @foo[0] instead of $foo[0] would
produce incorrect results, rather than simply a warning message.
Thank you,
Paul Lalli
--
--
Paul Lalli
Senior Software Engineer
ES11 Information Systems
8 Stanley Circle, Suite #8
Latham, NY 12110
p 518-782-1111
f 518-782-1212
e (e-mail address removed)