Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks!

I have a Perl program that runs from the command prompt, and gets called from a schedule task (Windows Machine). The problem I have is how to pass parameters from this line in my code:
my $zips = `perl c:\mycode\get_all.cgi`;


I have to pass parameters like:
'c:\mycode\get_all.cgi?who=me&loc=us&state=ma'

And course it doesn't work, can anyone show me how to pass parameters like that from a DOS prompt?

Thanks a lot!!!

Replies are listed 'Best First'.
Re: Perl Parameter
by ikegami (Patriarch) on Feb 01, 2007 at 22:19 UTC

    CGI has a debug mode you'll find useful.

    >perl -MCGI -MData::Dumper -e"print Dumper { CGI::Vars() }" "a=b&c=d" $VAR1 = { 'a' => 'b', 'c' => 'd' }; >perl -MCGI -MData::Dumper -e"print Dumper { CGI::Vars() }" a=b c=d $VAR1 = { 'a' => 'b', 'c' => 'd' };

    See the "DEBUGGING" section of CGI for more.

Re: Perl Parameter
by chromatic (Archbishop) on Feb 01, 2007 at 22:14 UTC

    That really depends on how your program parses its arguments. My guess is that putting them in the QUERY_STRING environment variable may work.

    However, may I suggest that an easier solution over the long term is to remove the specific processing from the program into its own module, then use that module from a command-line program as well as a separate CGI program?