Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Syntactic Confectionery Delight
 
PerlMonks  

Re: CGI Command Line

by barrachois (Pilgrim)
on Apr 12, 2004 at 17:16 UTC ( [id://344529]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to CGI Command Line

Use the CGI.pm module and follow the directions in its debugging documentation.

For example, if your script is in the file color.cgi

#!/usr/bin/perl -T use strict; use warnings; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/plain\n\n"; my $color=param('color'); print "Your chosen color is $color.\n";
then from the command line you can type
 ./color.cgi color=red
to see it run as it would from a URL like color.cgi?color=red

- barrachois

Replies are listed 'Best First'.
Re: Re: CGI Command Line
by JoeJaz (Monk) on Apr 12, 2004 at 17:26 UTC
    I didn't realize that it was that simple. That's very useful Thanks a lot! Joe
Re: Re: CGI Command Line
by bhappy (Scribe) on Apr 13, 2004 at 08:08 UTC
    I also like using Data::Dumper when debugging my CGI scripts.
    #!/usr/bin/perl -T use strict; use warnings; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use Data::Dumper; print "Content-type: text/plain\n\n"; my $color=param('color'); print Dumper($color); exit; print "Your chosen color is $color.\n";
    # ./color.cgi color=red Content-type: text/plain $VAR1 = 'red';
    It's useful when the script is big and all you want is to check a variable in a middle of it.
      Ooh! Very nice! That's soo much easier that writing my own code to do that type of debugging. Thanks for the tip! Joe

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://344529]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.