There are many options:
- exec(), if you want to start the other process and immediately exit your program
- system(), if you want to start the process and wait until it has finished to do some post processing
- backticks or qx if you want to run the other program and process its output
- IPC::Run or IPC::Open3 if you want even more interaction with the other program
| [reply] |
More options:
- Use the PHP module's embedded interpreter to run the PHP within your Perl script (may or may not work; I just know this exists, I've never used it myself)
- Given the similarities of PHP and Perl syntax, it may be simple to convert the PHP file to Perl and do all of the work in a single program. If the only purpose of the txt files is to communicate data to PHP, this could eliminate the need to create them at all.
| [reply] |
You should have the Perl daemon write the files to some sort of spool directory (don't forget, write in a tmp location, then mv it to the spool directory so it is atomic).
You should have another daemon watch this directory, then react accordingly when a file is detected. Ideally, this daemon should be written as a shell script. When a file is detected, you can handle it however you wish - this includes calling a PHP script...or doing anything else that is possible in a shell script.
I've actually written such a monitor daemon, and if you /msg me I'll send you the link to it. I think it'll suit your purpose well.
It is paired with a Perl utility that I wrote to extract data from "message files", which really just consists of ARG="value .." pairs. | [reply] |
If your PHP script sits under Apache, you can launch it by requesting your http://localhost/myspecialurl.
See HTTP::Request manual:
require HTTP::Request;
$request = HTTP::Request->new(GET => 'http://www.example.com/');
$ua = LWP::UserAgent->new;
$response = $ua->request($request);
| [reply] [d/l] |