Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by ggvaidya (Pilgrim)
on Sep 20, 2008 at 09:17 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-19 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found