toms -
Joined: 24 Jun 2004 Posts: 1
|
Posted: Sat Jun 26, 2004 4:40 am Post subject: Filtering a file via a Perl script |
|
|
I would like to run a Perl script whenever a pattern matches a file being served from htdocs.
For example if 'htdocs/try.txt' is being served I would like 'cgi-bin/filter.pl' to run first, read/filter 'try.txt', print a header, and then output the result to the browser (see below).
I tried setting up an interpreter 'cgi-bin/filter.pl', associating it with 'txt', and a path of '/*.txt' but can't get it to work.
I know this can be done with SSI but if this works then I should be able to use Abyss with HTML::Mason which is much more capable.
Am I missing something obvious?
Thanks,
Tom
Code: |
----------------------------------------------
filter.pl
----------------------------------------------
#!c:\perl\bin\perl.exe
use CGI ':standard';
$file = path_translated() ||
die "must be called with additional path info";
open (FILE,$file) || die "Can't open $file: $!\n";
print header('text/plain');
print "\n\n";
print "Filter.pl did this.\n\n";
while (<FILE>) {
print;
}
close FILE;
|
|
|