B
Bo Lindbergh
use strict;
use warnings;
my($index,@array);
$#array=2;
$index=0;
foreach my $element (@array) {
printf STDERR ("index=%d\n",$index++);
read(DATA,$element,2);
}
print STDERR "array=('",join("','",@array),"')\n";
__DATA__
Random line of text which is irrelevant to the matter.
With either 5.6.1 or 5.8.1, the above program prints this on STDERR:
index=0
index=1
Use of uninitialized value in read at oddity line 10.
index=2
Use of uninitialized value in read at oddity line 10.
array=('Ra','nd','om')
Why does read complain about an output-only parameter being undefined?
And why _doesn't_ it complain on the first iteration of the loop?
/Bo Lindbergh
use warnings;
my($index,@array);
$#array=2;
$index=0;
foreach my $element (@array) {
printf STDERR ("index=%d\n",$index++);
read(DATA,$element,2);
}
print STDERR "array=('",join("','",@array),"')\n";
__DATA__
Random line of text which is irrelevant to the matter.
With either 5.6.1 or 5.8.1, the above program prints this on STDERR:
index=0
index=1
Use of uninitialized value in read at oddity line 10.
index=2
Use of uninitialized value in read at oddity line 10.
array=('Ra','nd','om')
Why does read complain about an output-only parameter being undefined?
And why _doesn't_ it complain on the first iteration of the loop?
/Bo Lindbergh