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

Re: CGI Command Line

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


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


Comment on Re: CGI Command Line
Download Code
Replies are listed 'Best First'.
Re: Re: CGI Command Line
by bhappy (Scribe) on Apr 13, 2004 at 12: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
Re: Re: CGI Command Line
by JoeJaz (Monk) on Apr 12, 2004 at 21:26 UTC
    I didn't realize that it was that simple. That's very useful Thanks a lot! Joe

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2015-07-29 02:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls