473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Doubt in Perl exception handling

Hi,
I am a Perl newbie and have a doubt on Perl exception handling.
My understanding regarding exception handling is execute a piece of
code, if any exception occurs, handle the exception and proceed as if
the error never occurred at all.
So code would look like

Eval {
# do something
}; if ($@)
{
#handle exception
}
#procees as if no exception occurred

But in Perl I find that very often we die upon an exception. We never
try to handle the exception and continue. Is my understanding correct?
Is this the right way to do it?

TIA,
Babu

Jul 19 '05 #1
1 5756
In article <11**********************@g14g2000cwa.googlegroups .com>,
Babu <ba****************@gmail.com> wrote:
Hi,
I am a Perl newbie and have a doubt on Perl exception handling.
My understanding regarding exception handling is execute a piece of
code, if any exception occurs, handle the exception and proceed as if
the error never occurred at all.
So code would look like

Eval {
It's 'eva'. Case matters.
# do something
}; if ($@)
{
#handle exception
}
#procees as if no exception occurred

But in Perl I find that very often we die upon an exception. We never
try to handle the exception and continue. Is my understanding correct?
Is this the right way to do it?


The 'right way' to do it depends upon the application. I myself don't
use the eval { } method for trapping exceptions, because almost all of
the Perl programs I write are used by me and noboby else. Most of the
fatal errors in my Perl programs are caused by bad input or unforeseen
circumstances. When I encounter a fatal error, I analyze the cause and
modify my program to handle it.

On the other hand, were I writing programs for a production environment
in which the programs were used by others, I would pay much more
attention to trapping these unforeseen circumstances and dealing with
them somehow.

FYI: this newsgroup is defunct; try comp.lang.perl.misc in the future.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Mike | last post by:
I'm fairly new to PHP, but a long time Perl coder. This is probably answered somewhere, but I haven't been able to find it. The "strength" behind Perl is in its modules; are there modules...
6
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
77
by: Hunn E. Balsiche | last post by:
in term of its OO features, syntax consistencies, ease of use, and their development progress. I have not use python but heard about it quite often; and ruby, is it mature enough to be use for...
3
by: Master of C++ | last post by:
Hi, I am an absolute newbie to Exception Handling, and I am trying to retrofit exception handling to a LOT of C++ code that I've written earlier. I am just looking for a bare-bones, low-tech...
2
by: Baskar RajaSekharan | last post by:
Hi, In c# , If Client and the Server are in different machine, Can i through an Exception from the Server, so that the client can catch the Exception and do the appropriate action? Please give ...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
6
by: edu.mvk | last post by:
Hi, in the below statement : class A { int *i; A(){ };
6
by: surfivor | last post by:
I may be involved in a data migration project involving databases and creating XML feeds. Our site is PHP based, so I imagine the team might suggest PHP, but I had a look at the PHP documentation...
1
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.