Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

CGI redirect

by xyzzy (Pilgrim)
on Oct 29, 2009 at 18:20 UTC ( #804013=perlquestion: print w/ replies, xml ) Need Help??
xyzzy has asked for the wisdom of the Perl Monks concerning the following question:

I have a script using CGI (standard mode) which is failing oddly. The script looks something like this:

if (defined param('fnord')) { # open log file and append some params... redirect(-uri => 'http://whoisxyzzy.com/fnord/', -status => '303') +; } else { # do some other stuff... }

The script originally just handled a query and generated a corresponding page. Then I decided to add another parameter, which if present would dump to a log and redirect. Everything works, but if 'fnord' is included in the query instead of getting redirected I get a 500. The log file is still updated, even when I (originally) had the redirect call before the logging, and when 'fnord' is undef it works as it did before I decided to be clever and add this lack of functionality.

UPDATE: I am an idiot. redirect() does not actually redirect, it only generates the header and requires a preceding print statement. XYZZY OUT!

$,=qq.\n.;print q.\/\/____\/.,q./\ \ / / \\.,q. /_/__.,q..

Comment on CGI redirect
Select or Download Code
Re: CGI redirect
by moritz (Cardinal) on Oct 29, 2009 at 18:30 UTC
    Look in the error log of your web server, it will tell you more details than just a 500.
    Perl 6 - links to (nearly) everything that is Perl 6.
      Unfortunately the hosting service I signed up with uses cPanel and doesn't SSH. I have no idea where the actual logs are tucked away or if I can access them. The only "Error log" that is available only shows favicon 404s... but hey, it was cheap...
      $,=qq.\n.;print q.\/\/____\/.,q./\ \ / / \\.,q.    /_/__.,q..

        You still have options:

        • See if CGI::Carp qw(fatalsToBrowser); is of any use
        • Install a web server locally and test your script there
        • Run your script locally (without a web server) and see if you can make any sense of the output
        Perl 6 - links to (nearly) everything that is Perl 6.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (10)
As of 2014-07-10 13:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (211 votes), past polls