On Aug 27, 2000 at 12:17:41 -0500, Ken Williams twiddled the keys to say:
> [EMAIL PROTECTED] (Rick Myers) wrote:
> >I would lean towards the second one since upload_test() is called
> >similarly from three different places within request.t.
> >
> >The reasoning behind suggesting `while defined <FH>' was that the
> >interaction with $_ appears to be unintentional, at least within the
> >scope of upload_test(). We're basically throwing away the content of the
> >file read anyway, so why not just eliminate the undesired setting of $_
> >altogether. Also, there's no need to localize $_ since we aren't
> >referencing it to do anything.
> >
> >  for ( qw(perlfunc.pod perlpod.pod perlxs.pod), @binary) {
> >      upload_test($_);
> >  }
> >
> >  sub upload_test {
> >      my $podfile = shift || "func";
> >      ...
> >      ++$lines while defined <FH>;
> >  }
> >
> >FWIW, adding defined() was the perldiag-suggested fix for the problem
> >Ken was seeing. It also happens to fix the read-only error quite nicely
> >in this particular situation.
> 
> 
> Sounds good to me.  But I still can't reproduce the original read-only error. 
> The following code runs just fine for me under 5.004 and 5.005:
> 
>    @binary = "blah";
>    for ( qw(perlfunc.pod perlpod.pod perlxs.pod), @binary) {
>      upload_test($_);
>    }
> 
>    sub upload_test {
>      ++$lines while <STDIN>;
>    }
> 
> The only funny business is that <STDIN> clobbers $_, so that the various
> values iterated through in the for() loop all eventually get set to
> undef.

Aha!

perl5.00503 -e 'test($_) for qw(a b c); print "OK\n"; sub test {$_=0}'
OK

perl5.6.0 -e 'test($_) for qw(a b c); print "OK\n"; sub test {$_=0}'
Modification of a read-only value attempted at -e line 1.

Chalk one up for 5.6 I guess.

Rick Myers                            [EMAIL PROTECTED]
----------------------------------------------------
The Feynman Problem       1) Write down the problem.
Solving Algorithm         2) Think real hard.
                          3) Write down the answer.

Reply via email to