Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by dreadpiratepeter (Priest)
on Sep 15, 2008 at 16:56 UTC ( [id://711501]=note: print w/replies, xml ) Need Help??


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

First of all, the file open does not need to go into an eval. Secondly, as far as I can see the else will trigger on a successful run (ie no error)
Are you sure the uunwritable file is really unwritable? and that you arent just successfully opening the file?
UPDATE: Looking at the examples in the docs for Exception::Class they seem to make the assumption that your eval always throws an exception. Try changing
ref $e ? $e->rethrow : die $e;
to
ref $e ? $e->rethrow : die $e if $e;
It says that caught without args simply returns $@ (which if successful will be undef), so that will keep it from throwing the empty die you are seeing


-pete
"Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."

Replies are listed 'Best First'.
Re^6: Catching a 'division by zero' error with Exception::Class
by baurel (Sexton) on Sep 15, 2008 at 18:09 UTC
    > Are you sure the uunwritable file is really unwritable?
    OK, I think that's the problem. I made the file unread/unwritable (chmod 111) but this doesn't seems to make the file unwritable. Hmm... How can I raise this exception?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2024-04-26 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found