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
Explain the default scope of variables in perl?
How to do comment in perl?
What is the peculiarity of returning values by subroutines in perl?
How to prevent file truncation in perl?
How to copy a file in perl?
What are the arguments and what do they mean in perl programming?
you are required to replace a char in a string and store the number of replacements. How would you do that?
What are the advantages and disadvantages of perl language?
What are some common methods to all handles in perl?
What is “grep” function in perl?
Which functions in Perl allows you to include a module file or a module and what is the difference between them?
What is use of ‘->’ symbol?
Explain the difference between "my" and "local" variable scope declarations. ?
What does read () command do?
Explain about the applications of perl?