Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How would you trap error occurred in the perl program/file?

Answer Posted / prabhath kota

You can catch the errros by using eval function.
Keep your code in eval block some thing like shown below.
Eg.,
#################################
eval {
my $a = 0;
my $b = $a/0; #Dividing 0 with 0 is definitely an error
};

if ($@) {
print "\n Error in your code";
}


############################
-> Eval block always ends with a semi-colon. $@ will catch
the errors persent.

-> If any errors are present $@ will be set otherwise $@
will not be set

-> Unfortunately in Perl we don't have Explicit Error
handling techniques like some other languages like java etc
I mean like IOException etc.,

Is This Answer Correct ?    5 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to renaming a file in perl programming?

969


Which guidelines by Perl modules must be followed?

961


What are the reasons that cookie server can’t handle multiple connections?

903


What is the difference between single (') and double (") quote in a string in perl?

899


How to open a directory in perl?

1022


How do I pass a command line argument in perl?

918


What can be done for efficient parameter passing in perl? Explain.

957


What is perl pop array function?

880


How can we create perl programs in unix, windows nt, macintosh and os/2 ?

831


How to access parameters passed to a subroutine in perl?

900


How to replace perl array elements?

894


Explain join function in perl?

881


How can I display all array element in which each element will display on next line in perl ?

860


Mention what is cpan?

950


What are the advantages of perl programming?

938