Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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
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
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

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 chanting in the Monastery: (7)
As of 2014-12-27 21:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls