in reply to command prompt help

QUERY_STRING is merely an environment variable, usually set by the web server and passed to your program. For a command line version, just set the environment variable to whatever you want, or use CGI as mentioned above.

A quick hack to get the program to work as you have typed it (the first version) is to add this to the top of your program:

$ENV{'QUERY_STRING'} = shift;
Ugly, but it should work.

You may also need to add this line:

$ENV{'REQUEST_METHOD'}="GET";
depending on what code you are using to parse the input.