How would you trap error occurred in the perl program/file?

Answer Posted / perly_whirly

Put your code inside of an eval. If an error occurs, the $@ variable will contain
the error. You can also raise an error by using die inside of an eval.

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose of _package_ literal?

537


What are the arguments and what do they mean in perl programming?

522


What does file test operators do in perl?

506


Explain splicing of arrays?

526


What is -> symbol in perl?

573






How to convert strings into an array in perl?

517


Write a program to show the process of spawning a child process

449


What is “grep” function in perl?

566


Differentiate use and require?

527


If you want to empty an array then how would you do that?

577


What are the advantages of c over Perl?

526


What is grep used for in perl?

529


How do I generate a list of all .html files in a directory?

531


I have one question regarding to eval function. I know eval function is use for error checking but I am not able to understand below line. eval \'exec perl -S $0 ${1+\"$@\"}\' if 0; $0 for script name $@ set if error occur

1612


What can be done for efficient parameter passing in perl?

478