Web query string -> cli args

  • 17 years ago

    How would I take the ?whatever=3;blah=what that goes in a URL
    and pass that as a command-line argument instead to perl.exe?


    Thanks in advance,
    - Mike


  • 17 years ago

    are u submitting an html form with the GET method to ur script? if so then u will be able to access everything that u have submited thru $ENV{'QUERYSTRING'}. then u havta split the data into 2 parts - the field names, and their values. u can do it this way:
    @data = split /&/ , $ENV{'QUERY
    STRING'}; #this will put every name=value pair as separate elements into the array.
    then you can create a hash that will hold all your data like this:
    for ( @data ) {
    ( $key , $value ) = split /=/ , $_;
    $dataset{$key} = $value;
    }
    and ur done! now you can access ur data like this:
    $dataset{watever} will return "3", and $dataset{blah} will return "what".
    and you can work ur way from there.

  • 17 years ago

    No, I'm running scripts from my program (a web server)
    and I can't figure out how to pass the query string
    to the perl interpreter (PERL.EXE).


    Thanks for trying!

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook