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

Hi,

Has anyone here had any experience with Perl and Apache2 not working as expected?

The problem I am talking about is when and undefined variable is used, the apache server sits there for ages before eventually returning a timeout.
# Example code #!/usr/bin/perl my $blah = 0; # have not defined $result if ($blah == 1) { $result == "true" } if ($result eq "true") { print "True" }
Code like this will work if called from the command line but not through the apache2 server.

Now I know you are going to say "Define your variables / use strict..." but this is old code that is in the process of being rewritten and it is not worth the hassle of going through the old stuff and fixing it up.

The code used to work with Apache 1.3.

Anyone have any ideas?

Cheers,
Reagen

Update: Actually "use strict" doesnt even kill the script. It still sits there doing something for ever... nothing in the error logs either.

Update 2: Trying to narrow down this prob and it seems that you can "use strict" and declare a variable but if that variable is used later in a context where its value is nothing, the server will do its timeout thing. Setting the value of that var to "" makes it work.

Replies are listed 'Best First'.
Re: Perl and Apache2 timeout
by Joost (Canon) on May 29, 2004 at 08:37 UTC
    I've seen this problem too, and apache 2 perl/CGI does seem to exit with the correct error (I always use strict) after a long time (5 - 10 minutes or so) . I haven't found any way of fixing the problem - it's really annoying when you're testing code - so in the end I installed apache 1.3; problem solved.

    I was using RedHat 9 and if you are too, it might also be something in RedHat's apache/perl version - you could try updating apache and/or perl.

      I was using Apache 1.3 until last night :(
      I had the problem on my FC1 box (but dont really mind cause I am a lot better at coding now than when I wrote these scripts) and last night upgraded Apache on my RH7.2 box and it started happening.
      Tried searching the web and found nada, which is wierd considering that an out of the box install of FC1 has it...
      Oh well. at least i can switch apache 1.3 back on when i give up for the day :).
      how do you update perl when you are in the urpmi hell?

      I guess that the only 2 ways are:

      • Upgrading your whole system.
      • Or, installing a paralell perl with its bundles.

      Am I right?

      .{\('v')/}
      _`(___)' __________________________
        I did the same as Joost....