On Aug 26, 2000 at 14:07:26 +0200, Stas Bekman twiddled the keys to say:
> On Fri, 25 Aug 2000, Rick Myers wrote:
>
> > On Aug 24, 2000 at 23:15:15 -0500, Ken Williams twiddled the keys to say:
> > > [EMAIL PROTECTED] (Rick Myers) wrote:
> > > >On Aug 24, 2000 at 01:15:57 -0500, Ken Williams twiddled the keys to say:
> > > >> The following patch eliminates a warning during 'make test' about 'Value
> > > >> of <HANDLE> construct can be "0";'. No biggie, but it should be fixed.
> > > >>
> > > >> ________________________________________________________________
> > > >> --- t/modules/request.t 2000/05/12 03:43:24 1.8
> > > >> +++ t/modules/request.t 2000/08/24 06:07:40
> > > >> @@ -125,7 +125,7 @@
> > > >> my $lines = 0;
> > > >> local *FH;
> > > >> open FH, $file or die "open $file $!";
> > > >> - ++$lines while (my $dummy = <FH>);
> > > >> + ++$lines while <FH>;
> > > >> close FH;
> > > >> my(@headers);
> > > >> if ($Is_dougm) {
> > > >> ________________________________________________________________
> > > >
> > > >This reverses a previous patch that fixes a fatal 'Modification of a
> > > >read-only value attempted at modules/request.t line 128', which returns
> > > >with this patch.
> > > >
> > > >See if this one finds us a happy median...
> > > >
> > > >--- t/modules/request.t~ Thu Aug 24 18:24:39 2000
> > > >+++ t/modules/request.t Thu Aug 24 18:41:22 2000
> > > >@@ -125,7 +125,7 @@
> > > > my $lines = 0;
> > > > local *FH;
> > > > open FH, $file or die "open $file $!";
> > > >- ++$lines while (my $dummy = <FH>);
> > > >+ ++$lines while defined <FH>;
> > > > close FH;
> > > > my(@headers);
> > > > if ($Is_dougm) {
> > >
> > >
> > > THAT's weird - what in the world is the read-only value that's being
> > > modified?
> >
> > It's $_.
> >
> > Here's the relevant code from request.t to illustrate...
> >
> > for ( qw(perlfunc.pod perlpod.pod perlxs.pod), @binary) {
> > upload_test($_);
> > }
> >
> > sub upload_test {
> > ++$lines while <FH>;
> > }
>
> The real fix should be either:
>
> for my $file ( qw(perlfunc.pod perlpod.pod perlxs.pod), @binary) {
> upload_test($file);
> }
>
> sub upload_test {
> ++$lines while <FH>;
> }
>
> or
>
> for ( qw(perlfunc.pod perlpod.pod perlxs.pod), @binary) {
> upload_test($_);
> }
>
> sub upload_test {
> local $_;
> ++$lines while <FH>;
> }
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.
Rick Myers [EMAIL PROTECTED]
----------------------------------------------------
The Feynman Problem 1) Write down the problem.
Solving Algorithm 2) Think real hard.
3) Write down the answer.