Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Using Perl To Redirect To Other Pages

by thatguy (Parson)
on Dec 03, 2002 at 19:33 UTC ( #217322=note: print w/replies, xml ) Need Help??

in reply to Using Perl To Redirect To Other Pages

quick and dirty:
my $url=""; my $t=1; # time until redirect activates print "<META HTTP-EQUIV=refresh CONTENT=\"$t;URL=$url\">\n";


use CGI; my $query=new CGI; print $query->redirect('');

Updated: changed the time until redirect so as not to break the back button per LTjake's suggestion.

Replies are listed 'Best First'.
Re: Re: Using Perl To Redirect To Other Pages
by LTjake (Prior) on Dec 03, 2002 at 19:52 UTC
    Minor point, but this "tip" says not to use META refresh for redirection.

    print "Location:\n\n";
    is a better "quick-n-dirty"?

    Update: Whoops. Fixed code - missed newlines - hat tip: Cody Pendant.

    Rock is dead. Long live paper and scissors!
      print "Location:";

      Doesn't that need a couple of newlines after it to work?

      ($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;
      I agree, Cody. Why do people submit solutions that require others to load the submitters HUGE (favorite) Library of overcoded functions when there is such simple solutions?

        If the question asked for how to use HTTP to redirect, I'd probably think to give the print "Location..." answer but when asked for cgi, even in lowercase, we do tend to think of Plus, though the print "Loc..." works, it is short on headers. It's fine to do it yourself but doing it right is usually easier through an interface. Even one that is less than ideal.

        ~>perl -MCGI -le 'print CGI::redirect("")' Status: 302 Found Location:
        Because perlmonks isn't HTTP monks; because you didn't want to learn HTTP; because HUGE (favorite) Library of overcoded functions keeps you from having to learn HTTP.
      The beauty of the simple. Thanks!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://217322]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2020-06-05 00:53 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (35 votes). Check out past polls.