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
Assuming both a local($var) and a my($var) exist, what's the difference between ${var} and ${"var"}?
What is subroutine in perl?
Can inheritance be used in perl?
Which functions in perl allows you to include a module file. State their differences.
How can information be put into hashes?
What is perl unshift array function?
What are the logical operators used for small scale operations? Explain them briefly.
How to determine strings length in perl?
what is Chop & Chomp function does?
Write a script to reverse a string without using perl's built in functions?
What does read () command do?
If EXPR is an arbitrary expression, what is the difference between $Foo::{EXPR} and *{"Foo::".EXPR}?
Write an example explaining the use of symbol tables.
What is it meants by '$_'?
Which functions in perl allows you to include a module file.