A Perl of an idea for try … catch clauses
3 January, 2007 – 10:20 amThe try…catch…finally clause found in languages like Java are very handy for error handling. In scripting languages like Perl you can achieve the same effect using the eval function as the following code snippet demonstrates.
eval{ &yourSubRoutine($parameters); };
$@ ? $yourLogObject->yourErrorMethod("I failed with reason: $@") ):
$yourLogObject->yourTraceMethod("Everything was good: $?") );








