in reply to Re: CGI Input with Escaped Characters
in thread CGI Input with Escaped Characters

That looks correct, and may work, but I try to keep the Perl code so that it'll work from command line too for troubleshooting. When I output the $ENV{} from command line, it doesn't show to that as an available key. Would that only work from a web posting action? Thanks!
  • Comment on Re^2: CGI Input with Escaped Characters

Replies are listed 'Best First'.
Re^3: CGI Input with Escaped Characters
by shmem (Chancellor) on Apr 02, 2017 at 17:08 UTC

    You can pass CGI parameters on the command, using data=foo api_key=1234. See the DEBUGGING section of CGI. But I doubt that CGI will shoehorn that back into %ENV.

    You could set the environment variable on the command line also

    $ env QUERY_STRING=data=foo&api_key=laurel%26hardy script.cgi

    or you could check inside your script if it is run from the commandline:

    if (-t STDIN) { # command line. for params, substitute special chars (e.g. & => %2 +6) # (there must be a module out there which does that for you) } else { # via webserver }
    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'