in reply to Re^2: Running a CGI script from a command line?
in thread Running a CGI script from a command line?

OK, time for a SSCCE. See if you can follow this simple illustration. If not, please reply and explain explicitly which bit you cannot reproduce or do not understand.

bash-$ cat my.cgi #!/usr/bin/perl use strict; use warnings; use CGI::Lite (); my $cgi = CGI::Lite->new; $cgi->parse_form_data; print "Content-type: text/plain\n\n"; $cgi->print_form_data; bash-$ export REQUEST_METHOD=GET bash-$ export QUERY_STRING='foo=bar&baz=quux' bash-$ ./my.cgi Content-type: text/plain foo = bar baz = quux

In this example I have shown you the trivial CGI code, demonstrated how to set the two key environment variables from within the shell (any Bourne-like shell will use this syntax) and then run the script from within the same shell process to show that it has processed the supplied query string.

Note, I've used CGI::Lite here for brevity but any of the CGI modules from CPAN should work in a similar fashion as explained by afoken above.

Update: Amended $PS1 for even more clarity, just in case.