Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^4: Catching a 'division by zero' error with Exception::Class

by ggvaidya (Pilgrim)
on Sep 20, 2008 at 09:17 UTC ( #712712=note: print w/replies, xml ) Need Help??

in reply to Re^3: Catching a 'division by zero' error with Exception::Class
in thread Catching a 'division by zero' error with Exception::Class

Thanks for pointing that out! I've put a "use 5.10" line in so it won't run unchanged on pre-5.10 perls. Do you think that's good enough?
  • Comment on Re^4: Catching a 'division by zero' error with Exception::Class

Replies are listed 'Best First'.
Re^5: Catching a 'division by zero' error with Exception::Class
by mr_mischief (Monsignor) on Sep 22, 2008 at 14:23 UTC
    It still exits the shell under which perl is running if it's pasted into 5.8.8's standard input.

    This version still issues commands to the shell but one of them isn't an exit:

    use warnings; use strict; use 5.0100; eval { print 10/0; # equivalent to: die "Illegal division by zero"; }; if($@) { if($@ =~ /Illegal division by zero/) { print "I feel funny\n"; exit; } else { die $@; } } # No exception thrown. print "What do you know, Perl can divide by zero.\n";

    When the code is placed in a file, a proper insufficient version abend happens.

    I'm not sure why exactly this is, but it is obviously some sort of issue with use version; not being processed as one might expect when the code source is standard input. I'm not sure in general how important that is to have fixed, since it is kind of a degenerate case. It'd be useful for example snippets, though, if pasting into the standard input stream worked the same way as writing to a file and calling perl with that file as an argument.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://712712]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2019-06-17 23:02 GMT
Find Nodes?
    Voting Booth?
    Is there a future for codeless software?

    Results (80 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!