How would you trap error occurred in the perl program/file?
Answer Posted / shah faisal
#Ist trapping the error in a block
eval {
# perl code goes here
};
if ($@) { # $@ is a special variable containing the error
if any else blank
print "Print your own error If u want";
}
# 2nd
# use if or unless for a loop ;ike below
if(chk some condition)
{
die"$!\n"; # if the condition success
}
system generated error is printed and the scirpt is exited
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How to remove a directory in perl?
What are the reasons that cookie server can’t handle multiple connections?
You want to concatenate strings with perl. How would you do that?
How to access parameters passed to a subroutine in perl?
How to close a file in perl?
Write a program to download the contents from www.perlinterview.com/answers.php website in Perl.
Explain a tell function in perl?
What are the benefits of perl in using it as a web-based application?
What does the qx{ } operator do?
Explain different types of perl operators.
Explain what is the scalar data and scalar variables in Perl?
Hi, I am a accountant. I am preparing a balance sheet but because of staff shortage and time pressures I cant complete it on time. There is lot of common data with last years which I need not retype and I can manage by editing last year’s balance sheet ? Is their any software on net where I can do this easily??
How to sort arrays in perl?
In Perl, what is grep function used for?
How to open and read data files with Perl