http://qs321.pair.com?node_id=74587

aykes has asked for the wisdom of the Perl Monks concerning the following question: (http and ftp clients)

I have a perl program (running on windows). I want to run it through a webpage (local on my computer). Is the a way for HTML to run 'perl myprogram.pl?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: trying to run a perl program in HTML
by tinman (Curate) on Apr 23, 2001 at 00:13 UTC

    You need to install a webserver on your computer.. use IIS, PWS, or even Apache for Win32..

    Next, write a HTML form as so..

    <form action="launcher.pl" method="post"> <input type="submit" name="sub" value="Run this!"> </form>
    on your page..

    Inside your launcher.pl CGI script (yes, you've writen a CGI script now), execute the Perl script that you want using exec or system or backticks like so..

    #!c:/perl/bin -w use strict; use CGI; my $q = new CGI; my $path_to_program = "c:/perl/myprog/prog.pl"; my $return_value = system("c:/perl/bin/perl.exe",$path_to_program); # this is the actual execution of the script. # now you can put a message to the user print $q->header; # send correct header, text/html # put HTML here

    It might be best if you restrict access to this script to ONLY your machine..
    HTH

Re: trying to run a perl program in HTML
by epoptai (Curate) on Apr 23, 2001 at 00:09 UTC
    You need to set up a webserver with Common Gateway Interface (CGI) to execute perl scripts on your local computer. Meanwhile you can capture the HTML output of a script with something like perl myprogram.pl >myprogram.html to view static pages in a browser.
Re: trying to run a perl program in HTML
by tomhukins (Curate) on May 10, 2001 at 17:33 UTC
    If you use ActivePerl, you can write client side Perl scripts, just as you might write client side Javascript. Be aware of the security implications of doing this: you don't want malicious Web pages to include things like unlink within <SCRIPT> tags, for example.