Click to See Complete Forum and Search --> : Perl Redirects
Nephalim
09-11-2002, 12:44 PM
/I keep trying to get into perl./& It is difficult for me to pick up\/ after using php.|Anywho... i'm trying to do a page redirect and have been unsuccessful.> I'm using ActivePerl/XP Pro and have the following line:
print "Location:$url";
The browser thinks for awhile and then timesout or displays the line "Location:index.htm" (that being the url) on the page. Everything else i've done seems to work okay.
Grizzly
09-11-2002, 03:24 PM
I think you're forgetting the 2 newline characters which are required after an HTTP header:
#!/usr/bin/perl
print "Location: http://somehost.com\n\n";
And if you're coming from PHP => Perl, you might find this resource extreemly helpful:
http://www.cs.wcupa.edu/~rkline/csc417/Perl2Php/
Nephalim
09-11-2002, 04:48 PM
No dice... could it be because i'm using ActivePerl on WinXP? Sup wit that... using:
print "Location: ../main.htm\n\n";last
I get Location: ../main.htm
once the script is run. I've also tried 'http://localhost/main.htm' without success. ARG!
Grizzly
09-11-2002, 05:23 PM
Yeah - sounds like a Perl configuration issue. Exactly what did you setup as the path to Perl in the IIS extension mappings? What is the query string you're passing it?
Nephalim
09-11-2002, 05:59 PM
I figured it out... i had already printed the content-type as html/text. I take it that since i was printing to the header, I shouldn't be printing that unless i want to print html instead. This perl business is so crazy! Once again, thank you Grizzly for your informative help.
e_dawg
09-11-2002, 10:09 PM
Perl is just pure low-level scripting -- you have to output your own headers, unlike PHP that does it for you because it is a high-level web scripting language (Perl wasn't originally designed for the web).
You should probably also print out 'HTTP/1.0 302' for the status, since some browsers don't like just 'Location: [url]'.