Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Commenting out carpout causes script to hang

by punch_card_don (Curate)
on Oct 10, 2007 at 14:45 UTC ( [id://643974]=perlquestion: print w/replies, xml ) Need Help??

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

Mucky Monks,

It's the darndest thing - my script uses the DBI to retrieve some data from a MYSQL database then output it into a Template::Toolkit template. Among other things, these lines are included at the top of the script to give me useful debugging info:

use warnings; # load modules use CGI; use CGI::Carp qw(fatalsToBrowser); use DBI; use Template; use HTML::Entities; # error output BEGIN { use CGI::Carp qw(carpout); carpout(STDOUT); }
And everything runs hunky-dory. Script runs to completion just fine, no error messages output to the browser. So I'm done developing, time to turn off the error messages, so I comment out:
# BEGIN { # use CGI::Carp qw(carpout); # carpout(STDOUT); # }
And it hangs. Just sits there 'til the browser times out. Comment back in, runs just fine again.

What the hey?




Forget that fear of gravity,
Get a little savagery in your life.



UPDATE: Problem Solved

Many thanks to philcrow and ikegami - using their various suggestions, the script now runs just fine with carpout commented out. Here's how I applied their info:

Via telnet, used the "Script" unix command to start script logging into a text file

script debug.txt;
Then ran the perl script successfully by passing all the parameters needed
REMOTE_USER=username perl myscript.pl param_1=x param_2=y param_3=z;
Stop the script logger
exit;
This has the excellent result of outptting everything - error messages and html output - to the debug.txt file for review.

I found a few things, including a sub-routine that was present in two separate places (this script "includes" several others), and a whole whack of lines using undeclared variables in if-statements. Cleaning it all up magically made it run.

Replies are listed 'Best First'.
Re: Commenting out carpout causes script to hang
by philcrow (Priest) on Oct 10, 2007 at 15:28 UTC
    Is it possible that CGI::Carp was the only thing making headers? I read in the docs:
    Fatal errors will now be echoed to the browser as well as to the log. CGI::Carp arranges to send a minimal HTTP header to the browser...
    which makes me suspect that you aren't sending headers in any other way. But that's just my best guess without running any code.

    Phil

    The Gantry Web Framework Book is now available.
      Best guesses are what I'm looking for!

      But in this case

      print "Content-type: text/html\n\n";
      is the very next line in the script after what I posted above.
        Then my only other advice is to stop the script short at various points:
        print "got to here\n"; exit;
        Move it down until something goes wrong.

        Phil

        The Gantry Web Framework Book is now available.
Re: Commenting out carpout causes script to hang
by ikegami (Patriarch) on Oct 10, 2007 at 15:13 UTC
    Where does it hang?
      Click on the link that calls the script, browser says "loading...", but nothing happens, it eventually times out.

        If you think the problem is in the browser, then you should determine what data the browser received and determine why that's making it hang.

        However, it's much more likely that the browser is hanging because it didn't receive an answer. Therefore, I was asking "Where in your script does it hang?"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://643974]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-19 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found