Reputation: 2126
I have access to a Perl module that I call from my Web code passing it query parameter in the usual URI-encoded form (i.e. myperl.pl?var1=val2&var2-val2&var3=val3
) from AJAX or curl.
How do I test this same module from the command line?
Upvotes: 1
Views: 161
Reputation: 385496
Does it use the CGI module? If so, see the DEBUGGING section of the docs.
myperl.pl var1=val2&var2-val2&var3=val3
Upvotes: 3
Reputation: 162
If you are using CGI.pm then I believe the params() function returns parameters from the command line.
@vars = $query->param
For example
myperl.pl "var1=value1&var2=value2&var3=value3"
param() method will returned be variables as a list.
Upvotes: 2
Reputation: 183201
If it's a CGI script, then it presumably finds those variables by examining the QUERY_STRING
environment variable; so, you can try setting that variable from the shell. For example, if you're using Bash, you could write:
QUERY_STRING='var1=val2&var2=val2&var3=val3' perl myperl.pl
or if you prefer:
export QUERY_STRING='var1=val2&var2=val2&var3=val3'
perl myperl.pl
(Note that you will likely need to set other environment-variables as well, and perhaps standard input.)
Upvotes: 6
Reputation: 2239
As long as you set the program as executable under the properties then:
./program_name.pl param1 param2 param3
should work. Unless I misread the question.
Upvotes: 1