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 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