You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by John Whitnack <jw...@glja.com> on 2001/03/09 18:32:55 UTC

(Beginner) Problems with mod_perl

We are running Apache 1.3.17 and mod_perl 1.25 on Solaris 7. I have just
installed mod_perl onto my server and it has created a big problem. When
I type http://my.domain.name I get a error message:

    The document contained no data.
    Try again later, or contact the server's administrator

And in the error log I get:

    child pid 15965 exit signal Bus Error (10)

But when I type http://my.domain.name/index.html my index page loads no
problem. I have done nothing to httpd.conf file after I loaded mod_perl.

John Whitnack
jwhitnack@glja.com
Gilbert Laustsen Jung


Re: Newbie Questions

Posted by ___cliff rayman___ <cl...@genwax.com>.
julie wang wrote:

>
> replace that with if it is advise not to do so when using mod_perl??  The
> FAQ suggests using "goto" kind of statement.  I rather not use that.  What
> other alternatives do I have?  Thanks!
>

which FAQ suggested a goto statement?
if u are thinking that something like:
return REDIRECT;

is a return from subroutine statement that sends u to the REDIRECT label
somewhere, that is not the case.  return - exits u from the current sub and
the value after it is returned to the calling sub.  in this case REDIRECT is a
constant.

--
___cliff rayman___cliff@genwax.com___http://www.genwax.com/



Re: Newbie Questions

Posted by Pierre Phaneuf <pp...@ludusdesign.com>.
julie wang wrote:

> I'm new to Modperl.  I been programming as a perl programmer (not the best,
> but I'm trying to improve) and been told to try and code using mod_perl.  I
> got ORA's book on Apache Modules and was reading about how to code using
> mod_perl.  Am I right to assume mod_perl is more Apache conf. than anything
> else?  (if using Apache::Registry) I been coding perl using the -w flag as
> well as "use strict".  I shouldn't need to alter how I code Perl, right?

Well, yes, you at least have to take care of some additionnal things.

The most important thing to know is that your code could be called a
number of time before being "reset", where a regular CGI script is
called only once and dies right after, which let you have some
sloppiness that you can no longer afford with mod_perl.

Imagine that this code:

my($var) = 0;

sub handler {
  my($r) = @_;

  $r->content_type('text/plain');
  $r->send_http_header;

  $var = $var + 1;
  print "\$var is $var\n";

  return OK;
}

What you'll have with this is that you'll basically get a random number
for every requests. If you want to start this script assuming that $var
is 0, then set $var to 0 at the beginning.

> Is there anyway to test if the server is running in mod_perl or not?  I know
> this is one of the FAQ questions, but I didn't really understand.  I am
> using exit(0); and exit; to terminate my perl scripts.  What should I
> replace that with if it is advise not to do so when using mod_perl??  The
> FAQ suggests using "goto" kind of statement.  I rather not use that.  What
> other alternatives do I have?  Thanks!

In Apache::Registry scripts, the environment variable GATEWAY_INTERFACE
is set to 'CGI-Perl/1.1'.

In recent enough mod_perl, 'exit' (with or without parameter) is
overridden and will not hurt the server, but the cleaner way to exit an
Apache::Registry handler is with 'return'. I *think* you can return
something like "return REDIRECT" or "return SERVER_ERROR" if you want,
but I'm not sure (I only use PerlHandler scripts, not Apache::Registry).

-- 
Pierre Phaneuf
http://www3.sympatico.ca/pphaneuf/

Re: Newbie Questions

Posted by "Sean C. Brady" <se...@valueclick.com>.
julie wang wrote:

> HI!
>
> I'm new to Modperl.  I been programming as a perl programmer (not the best,
> but I'm trying to improve) and been told to try and code using mod_perl.  I
> got ORA's book on Apache Modules and was reading about how to code using
> mod_perl.

> Am I right to assume mod_perl is more Apache conf. than anything
> else?

I wouldn't make that assumption, althought it's a big part of it... but there's
so much more!


> (if using Apache::Registry) I been coding perl using the -w flag as
> well as "use strict".  I shouldn't need to alter how I code Perl, right?
>

Nope, you shouldn't have to alter too much... -w and strict are just fine...


>
> Is there anyway to test if the server is running in mod_perl or not?

tail -f Apache's error.log file - when you start up Apache, you'll probably see
a line with the configuration info - you'll see mod_perl in there.

> I know
> this is one of the FAQ questions, but I didn't really understand.  I am
> using exit(0); and exit; to terminate my perl scripts.  What should I
> replace that with if it is advise not to do so when using mod_perl??

I guess it depends on what you are trying to do... there are a number of ways
to exit your scripts..... some are right, some are not...  it's hard to say
without details of what you are trying to accomplish...

> The
> FAQ suggests using "goto" kind of statement.  I rather not use that.  What
> other alternatives do I have?  Thanks!
>
> -- Julie

~Sean


Re: Newbie Questions

Posted by Stas Bekman <st...@stason.org>.
On Fri, 9 Mar 2001, julie wang wrote:

> HI!
>
> I'm new to Modperl.  I been programming as a perl programmer (not the best,
> but I'm trying to improve) and been told to try and code using mod_perl.  I
> got ORA's book on Apache Modules and was reading about how to code using
> mod_perl.  Am I right to assume mod_perl is more Apache conf. than anything
> else?  (if using Apache::Registry) I been coding perl using the -w flag as
> well as "use strict".  I shouldn't need to alter how I code Perl, right?
>
> Is there anyway to test if the server is running in mod_perl or not?  I know
> this is one of the FAQ questions, but I didn't really understand.  I am
> using exit(0); and exit; to terminate my perl scripts.  What should I
> replace that with if it is advise not to do so when using mod_perl??  The
> FAQ suggests using "goto" kind of statement.  I rather not use that.  What
> other alternatives do I have?  Thanks!

Before the rain of questions comes in, please parse this pseudo-perl code:

  package Apache::AnyQuestions;
  use Apache::Constants;
  use constant SEEK_ANSWER => SEEK_CUR;
  sub handler{
    while (shift @questions){
      open RTFM, 'http://perl.apache.org/guide/' or die $!;
      while (still_not_found($_);)
        seek RTFM, 0, SEEK_ANSWER;
        read RTFM, $mind, 2**16;
        sleep 3600;
      }
      close RTFM;
    }
    return Apache::Constants::DECLINED;
  }
  1;

thanks :)


_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:stas@stason.org   http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



Newbie Questions

Posted by julie wang <ju...@e-haus.com>.
HI!

I'm new to Modperl.  I been programming as a perl programmer (not the best,
but I'm trying to improve) and been told to try and code using mod_perl.  I
got ORA's book on Apache Modules and was reading about how to code using
mod_perl.  Am I right to assume mod_perl is more Apache conf. than anything
else?  (if using Apache::Registry) I been coding perl using the -w flag as
well as "use strict".  I shouldn't need to alter how I code Perl, right?

Is there anyway to test if the server is running in mod_perl or not?  I know
this is one of the FAQ questions, but I didn't really understand.  I am
using exit(0); and exit; to terminate my perl scripts.  What should I
replace that with if it is advise not to do so when using mod_perl??  The
FAQ suggests using "goto" kind of statement.  I rather not use that.  What
other alternatives do I have?  Thanks!

-- Julie