in reply to oo code don't want to die !

The section on signal handling in perlman:perlipc suggests that although die can be used to jump out of handler (to an enclosing eval), it's better to adopt the strategy of setting a variable from within the handler, then checking the variable outside of the handler. In your case, this would look like:
my $caught_sigint = 0; local $SIG{INT} = sub { $caught_sigint = 1 }; foreach my $name ( @names ) { my $foo = new SUB::foo; $foo->name($name); ... last if $caught_sigint; } if ( $caught_sigint ) { die "<<pithy message here>>\n"; }

Replies are listed 'Best First'.
Re: Re: oo code don't want to die !
by iza (Monk) on Nov 29, 2001 at 16:51 UTC
    that's great ! it now stops & exit the loop :)
    it crashes badly from times to times tho, because sometimes the ^C interrupts an object that is doing "in-interrupt-able" stuff (for instance, while an XML::Parser is connecting to retrieve the dtd - things like that)
    but those are small things to fix (hopefully ...), and i'm really happy with your help :) - thanx for "translating" perlman:perlipc to me, i (obviously !) haden't properly understood this part