On Tue, Dec 15, 2009 at 6:34 PM, Shlomi Fish <shlo...@iglu.org.il> wrote:
> > You can use block eval {} instead of string eval "": > > <<<<<<<<<<<<<<<< > #!/usr/bin/perl > > use strict; > use warnings; > > my $x; > > eval > { > $x=12/0; > }; > > if ($@) > { > print "0 div error\n"; > } I did have tried that, but this will get a runtime error. # perl -e ' eval { $x = 12/0 }; if ($@) { print "0 div error" }' Illegal division by zero at -e line 2. My perl version: # perl -v This is perl, v5.8.8 built for i486-linux-thread-multi >>>>>>>>>>>>>>>>> > > One problem with that is that Perl 5's exception handling is not inherently > object-oriented. If you'd like that (and you likely would), look at the > following CPAN modules: > > * http://search.cpan.org/dist/Exception-Class/ > > * http://search.cpan.org/dist/TryCatch/ (never used it though). > > * http://search.cpan.org/dist/Try-Tiny/ (likewise). > Thanks Shlomi, I will check out them. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/