in reply to premature end of script headers?

Consult the server's error logs and you'll see that you're getting a prototype mismatch error because two things are trying to declare the subroutine head with different prototypes.

If you bother to read the documentation for LWP::Simple it explains just why you're getting that error and what the workaround is.

Note that if you are using both LWP::Simple and the very popular CGI.pm module, you may be importing a head function from each module, producing a warning like "Prototype mismatch: sub main::head ($) vs none". Get around this problem by just not importing LWP::Simple's head function, like so:
use LWP::Simple qw(!head); use CGI qw(:standard); # then only CGI.pm defines a head()
Then if you do need LWP::Simple's head function, you can just call it as LWP::Simple::head($url).

Replies are listed 'Best First'.
Re^2: premature end of script headers?
by imp (Priest) on Feb 22, 2007 at 17:56 UTC
    I agree that the change you suggested is recommended, but that shouldn't cause the problem he is experiencing as the warning is printed to STDERR and doesn't interfere with the header.

    I tested the script locally with apache 1.3.34 without any problems.

      Hrmm, quite correct that won't cause a 500.

      At any rate, the real next step should be to look at the error log and see what exactly the real error is that's causing the code to die and work from there.

      (And then fix things with use LWP::Simple qw( get ), of course :)