By itself, the web browser isn't going to execute a script for you, even if it lives on your local filesystem. The browser simply knows how to "ask" for something at a particular address.

In order for you to do something with the data, you're going to need a program that is listening for the request. That's why people are asking you about a web server. There are several ways you can create a simple web server on your machine to serve up your form and then process the results. I've not tried it personally, but I see that CPAN has HTTP::Server::Simple, which may be a good choice. (As I said, I've never used it, I'll defer to the other monks who have experience with web coding.)

Update: OK, I got really bored, so I installed HTTP::Simple::Server to give it a go. It was pretty simple, I just liberally cargo culted together something from the documentation, and it worked as advertised. I put the code in <readmore> tags so no-one has to look at it unless they're bored.

#!env perl { package sillyServer; use HTTP::Server::Simple::CGI; use base qw(HTTP::Server::Simple::CGI); use Data::Dump 'pp'; # URL paths to monitor my %dispatch = ( '/hello' => \&resp_hello, ); # Look up the path and execute the associated routine, or # give a typical 404 error sub handle_request { my ($self, $cgi) = @_; my $path = $cgi->path_info(); my $handler = $dispatch{$path}; if ("CODE" eq ref $handler) { print "HTTP/1.0 200 OK\r\n"; $handler->($cgi); return; } print "HTTP/1.0 404 Not found\r\n", $cgi->header, $cgi->start_html("Nada Darn Thing To C Here"), $cgi->h1("Nuttin here"), $cgi->end_html; } # handler for "/hello" sub resp_hello { my $cgi = shift; return if !ref $cgi; print $cgi->header, $cgi->start_html("Hello"), $cgi->h1("Hi there!\n"), $cgi->p("Parameters from \$cgi: ", pp($cgi->{param})), $cgi->p("Parameters from ENV: $ENV{QUERY_STRING}"), $cgi->end_html; } } # Start up the server use strict; use warnings; my $pid = sillyServer->new(8088)->run; print "PID = $pid, press ^C to stop\n"; my $t = <>;

Just enter "127.0.0.1/hello?Foo=bar" into your browser's address bar, and get a simple page that displays the parameters from the $cgi->{params} variable as well as from the %ENV variable.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re^7: parse $ENV{'QUERY_STRING'} by roboticus
in thread parse $ENV{'QUERY_STRING'} by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.