473,573 Members | 2,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5775
In article <11************ **********@g14g 2000cwa.googleg roups.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
2419
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 available like that for PHP? TIA, Mike
6
5938
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 is this... is Perl so much better at parsing text files and outputing that we would see a substantial speed increase? We process about 10 million...
77
4015
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 developing serious application, e.g web application as it has not many features in it yet. I've given up on Perl for its ugly syntax and it is not the...
3
2740
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 exception handling mechanism which will allow me to pass character information about an error and its location from lower-level classes. Can you...
2
1210
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 me some site address or any article related to this. Regards, R.Baskar
44
4187
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 user tasks should always be included in a try/catch block that actually handles any exceptions that occur (log the exception, display a message box,...
6
1472
by: edu.mvk | last post by:
Hi, in the below statement : class A { int *i; A(){ };
6
2990
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 for one of the Pear modules for creating XML and it didn't look like much. I've used Perl XML:Twig and I have the impression that there is more Perl...
1
3095
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
7781
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7788
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8066
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6421
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5292
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3733
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2216
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1304
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1041
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.