Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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 => '', -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..

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://804013]
Approved by Perlbotics
and John Coltrane plays...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2017-03-26 06:46 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (313 votes). Check out past polls.