in reply to Can Perl do this...?

What you're talking about is known in web development circles as CGI programming, and it's generally much easier to do in Perl than in C or most other languages. There are assorted ready-made modules available to make it even easier still. For example, you might want to look at CGI or CGI::Lite. As far as Apache, that's good news: Apache is generally very easy to work with. The first time I ever played around with CGI programming, I downloaded and installed Apache, configured it, wrote my Perl script, and had it working all in one afternoon. It wasn't the most elegant script ever (I was pretty new to Perl at the time), but it worked.

Here's what you need to know, then...

Here is a very minimal CGI script that you can use to test your setup to see that it's working:

#!C:\wherever\Perl.exe print "Content-type: text/html <html><head><title>test</title></head> <body><h1>It works.</h1></body></html> ";

update: Other monks' posts have made me look again at your request, and I think maybe you wanted to get the output from an external executable (written in C) and send _that_ to the user. This also is quite possible (maybe even easy, depending on how the executable takes its input). In the trivial case where the external program doesn't need any input but only generates output, this will work:

#!C:\wherever\Perl.exe open FOO, "C:\wherever\program.exe |"; # The | is a pipe; we're running program.exe and # reading its output from the FOO filehandle: print "Content-type: text/plain\n\n"; while (<FOO>) { print }

If the C script takes command-line arguments, that the user needs to specify, then you'll need to have an HTML form that lets the user specify this input, and your Perl script will take that input and massage it into command-line arguments for the external program. You can insert those arguments directly into the commandline, as in,

open FOO, "C:\wherever\program.exe @args |";

If the external program expects input in standard input, then post a reply saying so and we'll go into how to do that too.

It is also a good idea to make sure the program in question can't do anything destructive that you don't want, before turning loose a web interface straight to it. If possible, you should try to arrange for it to run as an unprivileged user, but I don't know enough about Windows 2000 to tell you how to do that.

If what the C program does is very simple, you may want to just rewrite it in Perl.


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/