CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: Premature End of Script Headers Error: Edit Log

Enthusiast / Moderator

Jul 6, 2001, 11:10 AM

Views: 677
Re: Premature End of Script Headers Error


Pro_4 is right, you should use the CGI package. Also, you should include CGI::Carp. A nice header for a CGI script to start is normally

#!/usr/local/bin/perl -wT 
use CGI qw(-no_debug :standard);
use CGI::Carp qw(fatalsToBrowser);
use strict;

The -no_debug is optional. It just stops CGI from always asking you for input when you're testing on the commandline.
The CGI::Carp will echo Perl errors to the browser, making script debugging a lot easier.
The use strict; will force clean Perl code.
With the CGI package, you can use

print redirect($redirect);

to print a standard redirection header. I've also noticed that you try comparing IP addresses with ==, but as you actually compare strings, you have to use eq. Using -w would have warned you.
Pro_4, there's no need for semicolons at the end of a block. But if your block isn't a one-liner, I'd recommand putting a semicolon there, too.
Hope this helps,

-- Marcus

(This post was edited by mhx on Jul 6, 2001, 10:38 AM)

This post has not been edited

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives