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
Where the command line arguments are stored and if you want to read command-line arguments with Perl, how would you do that?
How many types of primary data structures in Perl and what do they mean?
Why Perl aliases are considered to be faster than references?
Write an example explaining the use of symbol tables.
What is the use of -t?
what are the strategies followed for multiple form interaction in cgi programs?
What is cpan in perl?
What are scalars in perl?
What are prefix dereferencer?
Explain socket programming in perl?
List the files in current directory sorted by size ?
What is warn function in perl?
how to get back up from private character editor which is saved in the format of .udf
Give an example of using the -n and -p option.
Define operators used in perl?