tag:blogger.com,1999:blog-7760425276056032223.post7433639052157150946..comments2023-03-19T05:45:18.791-07:00Comments on PLABO: Basic exception handling in PerlPablo Marin-Garciahttp://www.blogger.com/profile/17942399687345864870noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-7760425276056032223.post-38700427084076001532010-03-24T18:00:22.039-07:002010-03-24T18:00:22.039-07:00[to nperez] I wanted to stress that eval{}......if...[to nperez] I wanted to stress that eval{}......if($@) is not a very good practice and that eval{}or do {} would be a better practice. But you are right and I should add some CPAN modules that deal with this like<br /><br /><a href="javascript:void(0);" rel="nofollow">TryCatch</a> # has more dependencies but is nicer than Try::Tiny<br /><br /><a href="http://search.cpan.org/dist/Error" rel="nofollow">Error</a><br /><a href="http://search.cpan.org/dist/Exception-Class" rel="nofollow"> Exception::Class</a>Pablo Marin-Garciahttps://www.blogger.com/profile/17942399687345864870noreply@blogger.comtag:blogger.com,1999:blog-7760425276056032223.post-45993990458711168122010-03-24T17:33:54.199-07:002010-03-24T17:33:54.199-07:00[to zby] I think that $@ in the catch block will c...[to zby] I think that $@ in the catch block will contain the right error message. This is the reason of recommending atomic try/catch with the 'or' in order to prevent $@ gets changed by other 'issues'. The point here is to discourage doing the eval{} and tenting $@ separately.Pablo Marin-Garciahttps://www.blogger.com/profile/17942399687345864870noreply@blogger.comtag:blogger.com,1999:blog-7760425276056032223.post-85877389852028483052010-03-24T17:20:51.492-07:002010-03-24T17:20:51.492-07:00[to anonymous] yes, many of the entries about perl...[to anonymous] yes, many of the entries about perl here are copy paste from popular Perl sites. You need to blame google and the closing of google-notebook ;-). So I am keeping here some interesting notes for myself, and puting the original link I giving to the source more google points ;-).Pablo Marin-Garciahttps://www.blogger.com/profile/17942399687345864870noreply@blogger.comtag:blogger.com,1999:blog-7760425276056032223.post-42574899027837595872010-03-24T12:23:59.025-07:002010-03-24T12:23:59.025-07:00Please see the Try::Tiny and TryCatch modules. Thi...Please see the Try::Tiny and TryCatch modules. This is a solved problem.NPEREZhttps://www.blogger.com/profile/07774396754686720265noreply@blogger.comtag:blogger.com,1999:blog-7760425276056032223.post-222703816974790792010-03-24T10:44:40.591-07:002010-03-24T10:44:40.591-07:00Note that AFAICT this blog is just a bunch of copy...Note that AFAICT this blog is just a bunch of copy-paste from popular Perl sites.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7760425276056032223.post-16699111238746684772010-03-24T10:17:57.659-07:002010-03-24T10:17:57.659-07:00This is interesting - but if we need to assume tha...This is interesting - but if we need to assume that $@ can contain something else then the error we are catching - then we also need to abstain from checking $@ in the <br /><br />} or do { # catch<br /> ...handle the error using $@...<br />};<br /><br />fragment.zbyhttps://www.blogger.com/profile/04636763782334128869noreply@blogger.com