Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

redirection without CGI.pm

by Anonymous Monk
on Sep 14, 2001 at 22:48 UTC ( [id://112494]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How can I create a drop-down menu redirection script within an HTML document that does not utilize CGI.pm Oh wise perl monks show me the path to enlightenment!

Replies are listed 'Best First'.
Re: redirection without CGI.pm
by arturo (Vicar) on Sep 14, 2001 at 23:07 UTC

    You'd use Javascript, or some other technology that embeds program instructions in HTML code. Perl can't, in general, be used *within* an HTML page without a special framework far more complex to set up than using CGI.pm. But assuming that what you seek is information on how you would write a script that would accept output from an HTML form and redirect the user's browser based on that output, you *should* use CGI.pm to gather that information, or failing that, CGI::Lite. Unless you have some very good reason for not wanting to use CGI.pm ?

    perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'
      I'm sure the gods of complete http headers will strike me for this one, but in a quick and dirty situation, this should function:

      As your first print statement send:

      print "Location: http://www.redirect.me/here\n\n";
      As I said before, this returns incomplete HTTP headers, however it should provide the desired function in an emergency situation.

      Heres an example (redirects you to yahoo):
      http://www.jerryfowler.net/redirect.cgi

      And here's the code:

      #!/usr/bin/perl print "Location: http://www.yahoo.com\n\n";
      -Jerry
      http://www.digilliance.net
Re: redirection without CGI.pm
by nardo (Friar) on Sep 14, 2001 at 23:06 UTC
    If you want to do it within an HTML document then you should use javascript and hope that your users have javascript enabled. If you want to do it within a perl CGI then you can print out a Location line in your header.
    print "Location: http://www.somewhere.com/\n"
    (you'll of course need another \n to terminate the header).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://112494]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-24 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found