- Code: Select all
#!"\xampp\perl\bin\perl.exe"
my %in = Vars(); # Get the CGI input variables
while ( (my $key, my $value) = each (%in) ) {
# Write to Raw.htm
print fLog "Raw: $key -> $in{$key}\n";
open (fHTMLraw, '>', $HTMLrawfile)
or HTMLdie ("File error: $!");
print fHTMLraw $value;
close fHTMLraw;
system( '..\php\php HTMLfilter.php' );
if (-e $HTMLpurefile){
open (fHTMLpure, '<', $HTMLpurefile);
$in{$key} = <fHTMLpure>;
close fHTMLpure; }
else {
$in{$key} = 'Purifier error';
print fLog "Purifier error"; }
print fLog "Pure: $key -> $in{$key}\n";
}
The only problem with this is that it pops up a command window for each iteration of the loop. But the results are fine.
There are other more complex but perhaps better ways to do this, and there are solutions for running PHP from Perl as well as running Perl from PHP:
http://devzone.zend.com/article/1712
http://www.cpan.org/modules/by-module/PHP/
http://pecl.php.net/package/perl