askgetanswer has asked for the wisdom of the Perl Monks concerning the following question:

i keep getting this error in apache error log :Apache2 IO flush: (103) Software caused connection abort at -e line 0 i checked online and read i need to use $r->print(), i was trying to use $r->print() instead of print, but all my codes are printed like print <<END1 html codes here END1 my question is how can i use $r->print() and instead of print <<END1 without chnageing entire code
  • Comment on maybe using $r->print() instead of print under mod_perl

Replies are listed 'Best First'.
Re: maybe using $r->print() instead of print under mod_perl
by remiah (Hermit) on Oct 27, 2011 at 01:07 UTC

    You will be warned for your question format.

    There seems 2 problems, one is about error log and anothoer is about here document like printing. At first, your program prints anything or not? If you pickup troubled lines into sample script, I can know your $r->print() prints anything or not... at least in my environment.

    I can print $r->print with configuration like this.

    #mod_perl test LoadModule perl_module /usr/local/libexec/apache22/mod_perl.so #there should be better way than this... <Perl> unshift @INC, '/usr/local/www/apache22/cgi-bin/test-modperl'; </Perl> PerlModule test1::sample <Directory /usr/local/www/apache22/cgi-bin/test-modperl/test1> SetHandler perl-script PerlHandler test1::sample </Directory>
    And $r->print in test1/sample.pm prints my text. I'm on FreeBSD 8.2, mod_perl2.0.5 .
    package test1::sample; use strict; use warnings; #old use Apache::Constants qw(OK); use Apache2::Const qw(OK); use Apache2::RequestRec(); use Apache2::RequestIO(); sub handler { my $r=shift; #old $r->send_http_header("text/plain"); $r->content_type("text/plain"); my $a=<<EOS test test test EOS ; $r->print($a); return OK; } 1;
    good luck for you. regards.