Gossamer Forum
Home : General : Perl Programming :

Perl redirect w/variables

Quote Reply
Perl redirect w/variables
I am trying to pass a variable in the redirect string, ie abc123, where the url value is in a hash that i want to extract, and then redirect to the corresponding url, but i am unsure as how to pull this value from the hash to pass it on .......

Quote Reply
Re: Perl redirect w/variables In reply to
How are you passing the variable into the URL?



Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Perl redirect w/variables In reply to
I hacked this together, but being a perl rookie, i would like to see what other methods would work. to pass the variable i did this:
www.blahblah.com/cgi-bin/redirect.cgi?link=abc123
then this variable 'abc123' then has to grab the correct value from the hash.

Quote Reply
Re: Perl redirect w/variables In reply to
Could you show me more of the code you are using.

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Perl redirect w/variables In reply to
this is the code that i used to make it work, turned out to be easier than i thought ... heh heh
*********** hash ****************
%goto_values = (
abc123_01 => "http://www.xxx.com/page1.html",
abc123_02 => "http://www.xxx.com/page2.html",
abc123_survey => "http://www.xxx.com/emailers/link.html"
);
************* end hash **************

$link = $goto_values{$fields{'link'}};

print "Content-type: text/html\n";
print ("Location: $link\n\n");

Quote Reply
Re: Perl redirect w/variables In reply to
just take out the print "Content-type: text/html\n\n";

you're not suppose to print headers when you redirect

Jerry Su
widgetz sucks
Quote Reply
Re: Perl redirect w/variables In reply to
it seems to work fine, so can you tell me why there should be no headers?
thanks

Quote Reply
Re: Perl redirect w/variables In reply to
Its because you arent printing any text on the page, you are re-directing to another URL.

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)