hi :)
sorry if the question sounds stupid, but i've read the die() doc, perlman::perlvar, and the oo tutorial, and haven't found nothing
sooo, what i'd like to do is to catch an interruption signal, and stop the program (doesn't look so hard ;]) - the point is that, as the program creates & calls some objects, it seems i have to wait for these objects to return before killing them (seems logical so far)
what i don't understand, is that those objects are created & used in a foreach loop, and my code seems to kill only the CURRENT object - then the loop goes on and creates the next object, while i'd like it to stop
maybe it's as simple as "your SIG{INT} isn't in the right place" or maybe is that i totally misunderstood perl's behaviour (hopefully not) ...
here is the code (part of)
my @list = split (....)
$SIG{INT} = \&catch_zap;
foreach my $nam (@list)
{
## Create foo object
my $foo = new SUB::foo;
$foo->name($nam);
...
my ($result, $error_message)=$foo->run;
...
## Save Data
my $file = ...;
open FH , "> $file" || die "Couldn't open file: $!";
...
print FH "$result \n";
close FH;
}
sub catch_zap
{
my $signame = shift;
&Warning("Somebody sent me a SIG$signame - trying to clean\n");
die "HEY I'M **done** STOP THIS PROGRAM __NOW__";
}
i let the file part in the foreach loop just to show there was something done after the call to "run"
so what happens is that the current object actually gets killed, i see the message from die, but the loop continues : the file is created, and then started again with a new object
if anyone knew where i fail, or how i could do to actually kill the program (exit the foreach loop, don't create the file, don't create nor call anymore object), i'd be really happy :))
thanx for having read ;]