On 3/21/06, Tom Allison <[EMAIL PROTECTED]> wrote:
>
> I'm trying to refactor an application I wrote a few months ago and ran
> into a question about SIG{TERM}.
>
> Currently I have a single application that uses the approach of:
>
> my $please_die = 0;
> $SIG{TERM} = sub {$please_die = 1 };
>
> to control when I should exit out of different loops and structures.
>
> But if I have a script that uses objects, how to I propogate this to the
> objects from the main script?
>
> The process to 'please_die' would be to exit nicely from each of the
> current objects and propogating this all back to the main script and
> closing out nicely.
>
> hints?

Just pass the object a reference to $please_die at some point. Either
accept it as a parameter to new, or create a method to set it. Either
way, store it in $self->{PLSDIE} or something similar. Any place you
want to break out using $please_die, just use a while loop:

        while ( ${$self->{PLSDIE}} < 1 ) {
            do {something} ;
        }

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to