Send a PHP array to a Perl script

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
First off, I am not sure where exactly to post this, so I'm posting to
both php.general and here...

My general problem is that I am wondering if there is a(n effective)
way to send an array from a PHP script to a Perl script. I am
developing a simple Perl script to handle automated e-mails from my
website (which is written exclusively in PHP). I would ordinarily just
stick with PHP as far as e-mailing is concerned, but I have found it
to be much more a pain trying to connect to my Gmail account via
sockets to send e-mail; the Perl route is much simpler in my opinion.

I have a form on my website that will let me specify to which users
from my site I would like to send the e-mail. Upon submitting the
form, the PHP script parses the e-mail addresses from
$_POST['user_emails'] and puts them into an array. Then what happens
is that I do something to the effect of:

foreach($user_emails as $user) {
[some code omitted here that generates the perl script]
shell_exec("perl \"./\"");


Essentially, what this does is sends out individual e-mails to each
user (it takes roughly 5-8 seconds for it to send out one e-mail, so
you can imagine if I try to send to 100 users that it takes quite a
while). But we all know that you can send a single e-mail to many
different people at the same time... This is why I am trying to send
PHP's array to my Perl script, because I could then easily add each
element in the array to one e-mail.

Any ideas? Sorry if my problem isn't clear (or if there is some
stupidly simple solution I am not thinking of... I'm not that fluent
in Perl yet).

Re: Send a PHP array to a Perl script

On Apr 21, 3:57=A0pm, wrote:
Quoted text here. Click to load it

You could build a string from your PHP's array contents, joined by
whatever delimiter (it should show up in the email addresses), and
then pass that to the Perl script. Within the Perl script, split the
string to get your individual email addresses back. There are a number
of Mail modules for Perl--I know of at least one that takes comma
separated emails (Mail::Sender, I think). Also, you could open a pipe
to Unix's mailx, which I think takes space delimited email addresses.


Site Timeline