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

I recently (yesterday) upgraded my Perl to 5.6.1 (from 5.6), and also upgraded CGI to the most recent version (from 2.78 to 2.81). I have a strange problem with a script that has worked just fine before the upgrade.

The script edits database rows, and takes in a fair bit of information from other database tables. When the script is called to either print out the rows of a table, or delete rows, it works fine. When it is called to enter data, or edit data, it seems to simply, barf. I don't have a better word for this, because the only error I get (if I get one) is "Premature end of script headers". Sometimes, if I have it print some output, it won't give me an error, but stop in the middle of the output. It's quite strange. Here's the first part of the code - the error definitely happens in here - it doesn't get further in the script.

#!/usr/bin/perl -wT use strict; use DBI; use CGI ':standard'; use Date::Calc qw(:all); use vars qw(@form_elements $login_id); ################################################################## # # parse the input form # ################################################################# my %query = (); my %configs = (); my %meta_configs = (); my $q = new CGI; foreach ($q->param) { $query{$_} = $q->param("$_"); } print $q->header; print $q->start_html(-title=>'XINA Database Editing'); ################################################################# # # Let's get the configurations necessary # ################################################################## # foreach (keys %query) {print; print":$query{$_}<br>\n";} # first, the meta_configs: my $meta_conf; if (!$query{meta}) {$meta_conf = "xina_meta.conf";} else { $meta_conf = $query{meta}; if ($meta_conf =~ /^([-\w.]+)$/) {$meta_conf = $1;} else {#will log it } } open (CONFIG, $meta_conf) or &graceful_exit("Can't open meta config fi +le!"); my @meta_configs_file = <CONFIG>; foreach (@meta_configs_file) { chomp; if (/^#|^\n/) { next; } else { (my $var, my $val, my @more_vals) = split ('='); if($var) {$var =~ s/\ $//;} if ($val) {$val =~ s/^\ //;} if ($var) { if(!$more_vals[0]) {$meta_configs{$var} = $val;} else { my $more_vals = join('=',@more_vals); $meta_configs{$var} = $val."=".$more_vals;} } } } foreach (keys %meta_configs) { print "$_:$meta_configs{$_}<br>\n";}
Suggestions, Ideas, things I'm stupidly missing? (It doesn't seem to matter how big the query string is - even sending small query info, by Post or Get, gives me the same result.)

Replies are listed 'Best First'.
Re: Strange problem on upgrading Perl and CGI
by jsprat (Curate) on Jul 03, 2002 at 22:00 UTC
    I have a couple of suggestions for debugging -

    Since you have warnings enabled and use strict;, let perl help you even more -
    use CGI::Carp qw/fatalsToBrowser/; while debugging the script (remove it in production). The server logs should have the actual error message as well.

    If that doesn't make things jump out at you, look here for a good troubleshooting guide.

    Lastly, you might try typing 'premature end of script headers' into the search box at the top of the page. Believe it or not, it's been discussed here before ;-)

      I very much appreciate the help - but I'm still stuck. I'd done all of the standard troubleshooting stuff I usually do, and is outlined in the guide. None of the earlier posts on this helped (I did a search here and google before I posted this question). I hadn't used CGI::Carp much before, and tried it, with no luck.

      The wierd thing about this error is: 1) the script works fine in all but two modes. 2) The script has been working fine for weeks until I upgraded my perl and CGI. 3) The script works fine on a different machine with the same versions of perl and CGI (different distro of Linux - Mandrake instead of debian). and 4) There are no errors that are clear, and sometimes output just stops cold, with no feedback whatever. 5) Plenty of other scripts seem to work just fine.

      There's nothing in any log (apache error_log, or syslog) that would help.

      So I'm stumped, but I need to solve this problem. I guess I'll have to try some other approaches (I'm not quite sure what...)

Re: Strange problem on upgrading Perl and CGI
by chromatic (Archbishop) on Jul 03, 2002 at 22:05 UTC
    Install Date::Calc for the new version. (Just a guess, but I have strong intuition on this one.)
      Sorry - wrong guess. It's up to date.