Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I'm really at a loss why I am getting a 500 error when I attempt to execute the following script via a Web browser and the following error in my error log:
[Mon Nov 27 13:49:00 2006] [error] [client] Premature end + of script headers: /home/www/cgi-bin/
The script WORKS fine on a server that has HTTP::Request::Common, but the error occurs on a machine where this module is not available. I added the eval assuming that it would effectively test if this module was available, and, if not, the error would be displayed on the Web browser (or I could suppress it entirely), and then I can continue doing other things without using the module. Here is the script...
#!/usr/bin/perl print "Content-type: text/html\n\n"; print "here we go again..."; eval { require LWP::UserAgent; use HTTP::Request::Common; my $ua = LWP::UserAgent->new; my %post; my $content = $ua->request(POST "", [%post]) +->as_string; print $content; }; if (@$) { print "ERROR: @$"; } print "more stuff would happen here";
My questions are: 1) why doesn't the use of eval successfully suppress the premature EOS error? 2) is there a better way to test if the module is available, and, if not, then don't use it, and do other things? Basically this script will execute on a few servers and I want to test if the modules are available, and, if so, then use them and do some things, BUT if they aren't, then don't use them and do some other things... WITHOUT causing 500 errors... help? Thanks!

In reply to Why am I getting "premature end of script header"? by lokiloki

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2022-10-07 19:04 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (30 votes). Check out past polls.