Re: Exception Handling in perl

2009-02-27 Thread Jenda Krynicky
Subject:Re: Exception Handling in perl From: David Shere To: "Sarsamkar, Paryushan" Copies to: beginners@perl.org Date sent: Fri, 27 Feb 2009 09:00:41 -0500 > On Fri, 2009-02-27 at 08:49 -0500, Davi

RE: Exception Handling in perl

2009-02-27 Thread Sarsamkar, Paryushan
Exception Handling in perl On Fri, 2009-02-27 at 08:49 -0500, David Shere wrote: > You can also have it do more than one thing: > copy ("C:\\build.xml","D:\\build.xml") or ( print "Cannot copy : $!" and > somethingElse() ); Or you can have more fun: unless (c

Re: Exception Handling in perl

2009-02-27 Thread David Shere
On Fri, 2009-02-27 at 08:49 -0500, David Shere wrote: > You can also have it do more than one thing: > copy ("C:\\build.xml","D:\\build.xml") or ( print "Cannot copy : $!" and > somethingElse() ); Or you can have more fun: unless (copy ("C:\\build.xml","D:\\build.xml")) { print "Cannot copy : $

Re: Exception Handling in perl

2009-02-27 Thread David Shere
On Fri, 2009-02-27 at 08:41 -0500, Sarsamkar, Paryushan wrote: > copy ("C:\\build.xml","D:\\build.xml") or die "Cannot copy : $!"; simplest (?) solution: copy ("C:\\build.xml","D:\\build.xml") or print "Cannot copy : $!"; You can also have it do more than one thing: copy ("C:\\build.xml","D:\\bui

Exception Handling in perl

2009-02-27 Thread Sarsamkar, Paryushan
Hi All, Can we handle exceptions in PERL programs? For example - Here if it fails to copy then can I handle the exception and perform the next steps in my script? I tried removing "die" but then it does not complain and I wont be able to come to know if that is copied or not. (Is there anyt

Re: Exception handling in perl

2007-07-12 Thread Ovid
- Original Message From: Pushkar Pande <[EMAIL PROTECTED]> > How do we handle exceptions in perl? If you want *proper* exception handling (exception objects, try/catch, stack traces, etc), the don't use: die $message; return 0; eval {}; # except with exception objects $SIG{__DI

Re: Exception handling in perl

2007-07-12 Thread Mr. Shawn H. Corey
Pushkar Pande wrote: How do we handle exceptions in perl? perldoc -f eval Example: eval { some code }; if( $@ ){ # an exception occurred } -- Just my 0.0002 million dollars worth, Shawn "For the things we have to learn before we can do them, we learn by doing them." Aristotle

Re: Exception handling in perl

2007-07-12 Thread Martin Barth
On Thu, 12 Jul 2007 16:06:27 +0530 "Pushkar Pande" <[EMAIL PROTECTED]> wrote: > How do we handle exceptions in perl? there is a Error.pm in CPAN, which allows you to write code like that try { something(); } catch Error with { code(); }otherwise{ foobar(); }; -- To

Exception handling in perl

2007-07-12 Thread Pushkar Pande
How do we handle exceptions in perl?