in reply to Objects and forking

Will each instance of $mailer in the children actually be the same object affecting the same data or will they be their own seperate entity containing only the data populated in $mailer up to the point of forking?

The latter.

I think tilly was warning you against letting each child use the same connection. They would use the same connection if the connection was opened prior to the fork. You can prevent them from sharing a connection by opening any connections after forking. (I'm not even sure you are opening any connections at all, for that matter.)

In other words, if in one child I change/add something via a $mailer method, will it affect the other processes?

No. It won't.

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re: Re: Objects and forking
by gnu@perl (Pilgrim) on Jul 11, 2003 at 13:40 UTC
    Tilly verified what I was thinking, from the point of the call to fork each entity is a seperate thing as far as data within it goes. File handles are another story though, since they are inherited from parent to child it would be a mess when the children went to send any output to them.
    What I am doing is creating an object containing some generic data (email addresses, subject, etc) that will be common amongst all children. Each child process will add its own pertinent information and do what it needs to with the object. Basically send an email alert with it's own data in the body of the email, but each child has the same 'To:' and 'Subject:'.