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 can you use Perl warnings and what is the importance to use them?
How do I do fill_in_the_blank for each file in a directory?
Write syntax to use grep function?
What $! In perl?
How to code in perl to implement the tail function in unix?
How to check the status of airplane mode (enable/disable) in perl for Android mobile?
Explain the meaning of subroutine?
Explain which feature of PERL provides code reusability?
What is q (single q) operator in perl?
How can information be put into hashes?
What are the various uses of perl?
When would `local $_' in a function ruin your day?
What are the different string manipulation operators in perl?
What is posix in perl?
What is subroutine in perl?