##
$SIG{INT} = sub {
# code executed on 'INT' signal here
}; # <-- that semicolon isn't optional
####
{
my $stop = 0;
local $SIG{INT} = sub { $stop++ };
while (!$stop) {
# the loop continues until it's left with an explict
# last, or until the process recieves SIGINT.
}
}
# our old SIGINT handle is restored here, because we
# left the old block.