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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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



mhx
Enthusiast / Moderator

Jul 6, 2001, 11:10 AM


Views: 665
Re: Premature End of Script Headers Error

Hi,

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

Code
#!/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

Code
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