March 2001
Intermediate to advanced
288 pages
4h 56m
English
Let's say that you want to go in the other direction and instead of turning errors into exceptions, you want to know when your program is about to die. The brute-force approach is to define a pseudo signal handler for __DIE__:
$SIG{__DIE__} = sub { print "Igor lives!\n" };
but this is rather ineffectual for several reasons. First, we don't know why the program is dying (without parsing the argument, which is an arbitrary string). Second, we don't know where the program is dying without parsing the line number out of the argument (but when you think about it, that information is absolutely useless inside your program). And third, the Faustian bargain that this handler has made lasts only as long as it does; as soon as the ...