[Melbourne-pm] Run Perl Script from HTML

Scott Penrose scottp at dd.com.au
Thu Sep 24 05:24:19 PDT 2009


On 24/09/2009, at 10:20 PM, Toby Wintermute wrote:

>
> Your Perl script can quite happily open up port 80 (or another,
> non-reserved port) and listen for HTTP requests upon it.
> (In effect, your Perl script becomes a stand-alone web server.)

Yes, as Toby has said here, you can do it by running Perl. And with  
Strawberry perl and PAR you should be able to do it with one or two  
clicks for the operator. E.g. it might be run the program then go to  
the URL.

Try HTTP::Daemon - I think it is fairly common

SYNOPSIS
          use HTTP::Daemon;
          use HTTP::Status;

          my $d = HTTP::Daemon->new || die;
          print "Please contact me at: <URL:", $d->url, ">\n";
          while (my $c = $d->accept) {
              while (my $r = $c->get_request) {
                  if ($r->method eq 'GET' and $r->url->path eq "/ 
xyzzy") {
                      # remember, this is *not* recommended practice :-)
                      $c->send_file_response("/etc/passwd");
                  }
                  else {
                      $c->send_error(RC_FORBIDDEN)
                  }
              }
              $c->close;
              undef($c);
          }


Scott



More information about the Melbourne-pm mailing list