I understand its usually a header has been already sent type scenario but I'm starting to lose it. I have no idea how to sniff out where I mucked up in my code. I tried using a print sub routine that prints both to stdout and to a file. I saved the file output as an html it works. So its not an html issue. But I have no idea how to find out where the premature header is being sent.

Recommended Answers

All 2 Replies

If you are talking about printing out to HTML as a file and it can be opened using a browser, it may be because a browser usually tries to correct the HTML and can display (almost) correct.

The problem with premature header could be from not closing scope or incorrectly closing scope. Also, how did you print it out? Using print <<HTML or use simple print? If you use print <<HTML, you will need to escape certain character in your string (especially the @). Can't say much unless we see your reduct code...

But I have no idea how to find out where the premature header is being sent.

How are you printing the html header?

Check this:

use warnings;
use strict;
use CGI qw/standard/;

 my $cgi = CGI->new();

 print  $cgi->header,  # header printed
        $cgi->start_html(-title => "Perl Programming"),

    $cgi->end_html;

Of course, you need to show how you are printing in your script.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.