Good morning,
On 2/10/04 at 10:46 AM -0400, Stas Bekman <[EMAIL PROTECTED]> wrote:
>> This is a common problem with mod_perl and OSX. Add the following to your
>> httpd.conf file:
>>
>> # fix for mod_perl print()
>> PerlHeaderParserHandler "sub { tie *STDOUT, 'Apache' unless tied *STDOUT; }"
>>
>> I don't understand why the problem exists or why this fixes it. I
>> took the advice (found it via some Google searching) and mod_perl
>> scripts now work for me.
>
>Most likely some core module untie's/re-tie's STDOUT after mod_perl had it
>tied. I'd love to have the guilty party discovered. It's have been easy if
>tie was overridable via CORE::GLOBAL::tie but it doesn't seem the case. So
>you probably need to set breakpoints at tie and untie to see which module
>messes with that.
That makes sense; thanks for the explanation. I don't particularly like
the perl command line debugger, especially when debugging mod_perl
scripts. So I thought a search through my perl lib for "tie " might
reveal the culprit. This is what I found:
$ grep -r 'tie ' /Library/Perl/5.8.1
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBD/DBM.pm: eval { tie %h,
$tie_class, @tie_args };
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBD/DBM.pm: untie %{$self->{hash}}
if $self->{hash};
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBD/DBM.pm: untie %{$self->{hash}}
if $self->{hash};
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI/DBD.pm:Because you have the inner
handle, tie magic doesn't get invoked
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI/PurePerl.pm: untie $DBI::err;
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI/PurePerl.pm: untie $DBI::errstr;
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI/PurePerl.pm: untie $DBI::state;
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI/PurePerl.pm: untie $DBI::rows;
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI/PurePerl.pm: #tie $DBI::lasth,
'DBI::var', '!lasth'; # special case: return boolean
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI.pm:tie $DBI::err, 'DBI::var',
'*err'; # special case: referenced via IHA list
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI.pm:tie $DBI::state, 'DBI::var',
'"state'; # special case: referenced via IHA list
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI.pm:tie $DBI::lasth, 'DBI::var',
'!lasth'; # special case: return boolean
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI.pm:tie $DBI::errstr, 'DBI::var',
'&errstr'; # call &errstr in last used pkg
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI.pm:tie $DBI::rows, 'DBI::var',
'&rows'; # call &rows in last used pkg
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI.pm:tie %DBI::DBI => 'DBI::DBI_tie';
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI.pm: $i = tie %hash, $class,
$attr; # ref to inner hash (for driver)
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI.pm: # The above tie and bless
may migrate down into _setup_handle()...
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI.pm:Because of the way the Perl tie
mechanism works you cannot reliably
/Library/Perl/5.8.1/HTML/Template.pm: tie %cache, 'IPC::SharedCache',
/Library/Perl/5.8.1/HTML/Template.pm: # the shared cache tie hold references to
$self! This was not easy
/Library/Perl/5.8.1/HTML/Template.pm: tie $result, 'HTML::Template::PRINTSCALAR',
$args{print_to}
/Library/Perl/5.8.1/IO/Zlib.pm: tie *FILE, 'IO::Zlib', "file.gz", "wb";
/Library/Perl/5.8.1/IO/Zlib.pm: tie *FILE, 'IO::Zlib', "file.gz", "rb";
/Library/Perl/5.8.1/IO/Zlib.pm: tie *{$self}, $class, @args;
/Library/Perl/5.8.1/Term/ReadLine/Perl.pm:tie %attribs, 'Term::ReadLine::Perl::Tie' or
die ;
/Library/Perl/5.8.1/WWW/RobotRules/AnyDBM_File.pm: tie %{$self->{'dbm'}},
'AnyDBM_File', $file, O_CREAT|O_RDWR, 0640
/Library/Perl/5.8.1/WWW/RobotRules/AnyDBM_File.pm: untie %{$self->{'dbm'}};
/Library/Perl/5.8.1/WWW/RobotRules/AnyDBM_File.pm: tie %{$self->{'dbm'}},
'AnyDBM_File', $file, O_TRUNC|O_RDWR, 0640;
The only one I can see which looks like a possible offender is
HTML::Template. The $args{print_to} is previously set to *STDOUT. If I
get a chance I'll setup a test config which doesn't use HTML::Template
and see of the problem goes away. Maybe Sam Wilkins can let us know
whether he is also using HTML::Template.
Charlie
--
Charlie Garrison <[EMAIL PROTECTED]>
PO Box 141, Windsor, NSW 2756, Australia
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html