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 is confess function in perl?

540


Explain chop?

534


What exactly is grooving and shortening of the array?

592


Explain tk?

517


What is -> symbol in perl?

568






Explain USE and REQUIREMENT statements?

553


What are the various advantages and disadvantages of perl?

462


Explain regular expression in perl?

527


Differences between die and exit.

614


Can inheritance be used in perl? Explain with the help of an example.

504


Which functions in perl allows you to include a module file.

496


How will you get the count of parameters passed to a perl subroutine?

534


How will you create a file in perl?

521


What is the function of virtual documents in cgi programs?

523


Write a script to reverse a string without using perl's built in functions?

503