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


Please Help Members By Posting Answers For Below Questions

What does last statement do in perl?

537


Explain the meaning of closure in perl.

537


List the operator used in Perl?

553


Explain string comparison operators in perl.

567


You want to concatenate strings with perl. How would you do that?

487






What are the various uses of perl?

535


Comment on data types and variables in perl.

517


What does cgi program store?

548


Explain goto expr?

503


What does next statement do in perl?

587


For a situation in programming, how can you determine that Perl is a suitable?

492


What is lexical variable in perl?

532


What is the main function of cookie server?

535


What is the different between array and hash in perl programming?

520


what is the main function of fork() in cgi programming?

556