Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
In an experiment that involved abusing Perl quite badly,
I discovered the "try/catch" method explored1 in The Camel Book,
which implements a pseudo-C++ style of error checking and
recovery. The usage is paraphrased here:
This is implemented using the ability of Perl to have anonymous subs passed as parameters to functions, provided they have a compatible prototype2 such as sub try(&$){}. Implementation details aside, has anyone used this try/catch method in Perl to any significant degree, or is there an alternative methodology that is more dependable? Just curious. Exceptions (i.e. die) in C++ are quite interesting. I am thinking that this might be used, for example, to more reliably trap DBI errors in Web applications. Or, of course, I might be completely delusional. 1. "Programming Perl", Chapter 2 - Prototypes 2. For some reason, you can only have the function as the first operator in your prototype, which works fine for map, grep, and what have you, but is strangely rigid considering the broader scope of Perl. In reply to Error Checking: Have you tried 'Try/Catch'? by tadman
|
|