Perl Redirects

Sharky Forums


Results 1 to 6 of 6

Thread: Perl Redirects

  1. #1
    Reef Shark Nephalim's Avatar
    Join Date
    Nov 2000
    Location
    Michigan
    Posts
    463

    Perl Redirects

    /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:
    Code:
    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.
    ~ And that is my humble opinion.

    When I was a boy I was told that anybody could become President. Now I'm beginning to believe it. - Clarence Darrow

    The greatness of a woman’s power is measured in the size and amount of the balls she clutches in hand. -Nephalim

    "Tink"
    1700+ XP on A7N8X, 768MB PC2700 DDRRAM, Samsung 19" 900IFT, Radeon 64MB DDR VIVO, SB Live! MP3+, 42.9GB IBM HDD, Plexwriter 8/4/32, 3C905CTXM NIC

    "Hermes"
    Dell Inspiron 8200, 1.7 GHz P4, 512MB DDRRAM, 30GB HDD, DVDROM, Geforce4 Go 64MB

  2. #2
    Ursus Arctos Moderatis Grizzly's Avatar
    Join Date
    Sep 2000
    Location
    Providence, RI USA
    Posts
    3,077
    I think you're forgetting the 2 newline characters which are required after an HTTP header:

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

  3. #3
    Reef Shark Nephalim's Avatar
    Join Date
    Nov 2000
    Location
    Michigan
    Posts
    463
    No dice... could it be because i'm using ActivePerl on WinXP? Sup wit that... using:
    Code:
    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!

  4. #4
    Ursus Arctos Moderatis Grizzly's Avatar
    Join Date
    Sep 2000
    Location
    Providence, RI USA
    Posts
    3,077
    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?

  5. #5
    Reef Shark Nephalim's Avatar
    Join Date
    Nov 2000
    Location
    Michigan
    Posts
    463
    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.

  6. #6
    Hammerhead Shark e_dawg's Avatar
    Join Date
    Jan 2001
    Location
    Earth, Western Hemisphere, North America, US, UT, SLC
    Posts
    2,628
    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]'.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •