Steve Hay wrote:
[...]
 sub table {
     $Table ||= parse_table(\*DATA);
+    close DATA;
+    return $Table;
 }



close DATA? but we have never opened it. What if this handler is reused second time under the same perl, it'll find the DATA fh closed? are you sure that this is the right solution?


The DATA filehandle is open already. From the "perldata" manpage:

"The filehandle is left open pointing to the contents after __DATA__. It is the program's responsibility to close DATA when it is done reading from it"

As you see, \*DATA is passed to parse_table(), which reads from it. We're supposed to close it afterwards, otherwise any subsequent error messages often confusingly refer to the last line that was read from DATA, e.g. just closing DATA but leaving the use of the uninitialised $ENV{HOME} changes the error from

I tend to think of it as a bug in perl, as I explained in my bug report (I just sent it out) it's perfectly valid for the DATA filehandle to be re-used on several invocations of the same function, where seek/tell can be used to move around the data. So closing it is a bad idea.


Use of uninitialized value in concatenation (.) or string at lib/ModPerl/BuildOptions.pm line 107, <DATA> line 20.

to

Use of uninitialized value in concatenation (.) or string at lib/ModPerl/BuildOptions.pm line 107.

As for the handler being re-used: Is this a handler at all? It never occurred to me that BuildOptions.pm would be getting used in a handler. I assumed it was only used in the build process, hence the error from it when running Makefile.PL.

sorry, I meant a function. When you are a hammer everything looks like a nail, when you do too much mod_perl, everything looks like a handler ;)


------------------------------------------------------------------------

--- BuildOptions.pm.orig 2003-10-07 19:28:38.000000000 +0100
+++ BuildOptions.pm 2003-10-16 08:47:34.504223900 +0100
@@ -105,7 +105,7 @@
my $fh;
my @files = map { $_ . 'makepl_args.mod_perl2' }
- qw(./ ../ ./. ../.), "$ENV{HOME}/.";
+ qw(./ ../ ./. ../.), (exists $ENV{HOME} ? "$ENV{HOME}/." : ());
unshift @files, $self->{MP_OPTIONS_FILE} if $self->{MP_OPTIONS_FILE};

I've committed a similar solution. Thanks Steve.


for my $file (@files) {
@@ -164,6 +164,8 @@
sub table {
$Table ||= parse_table(\*DATA);
+ close DATA;
+ return $Table;
}

Hopefully this will be resolved in perl, and since the warning is now removed, this shouldn't be a bother any longer.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to