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 does polymorphism work in perl? Give an example.
What does delete function do in perl?
How are parameters passed to subroutines in perl?
What are scalar data and scalar variables?
Write a program that shows the distinction between child and parent process?
what is Chop & Chomp function does?
Elaborate on perl bite-wise operators.
How will you get the count of parameters passed to a perl subroutine?
How will you create a file in perl?
How to open and read data files with Perl
How do you match one letter in the current locale?
Write the program to process a list of numbers.
What are numeric operators in perl?
What does init 5 and init 0 do?
What is the difference between use and require in perl programming?