Executing PHP script from Perl script

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Executing PHP script from Perl script

Postby PStechPaul » 26. January 2011 22:30

In my other post about sending email I showed how I was running a PHP script from Perl using a heredoc and <iframe>. It seemed to work, but actually it processed the HTML after the Perl script had run, so it was useless for what I wanted. Here is what I found to be the proper way to do this:

Code: Select all
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:
Posts: 7
Joined: 22. January 2011 02:38

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 59 guests