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
What does read () command do?
what is Perl one liner?
How to find the length of an array in perl?
Define say() function in perl?
Why aren't Perl's patterns regular expressions?
List the operator used in Perl?
What are perl array functions?
What is cpan in perl?
What is an interpolation in perl?
How do I sort a hash by the hash key?
What does Perl do if you try to exploit the execve(2) race involving setuid scripts?
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
In Perl, there are some arguments that are used frequently. What are that arguments and what do they mean?
package MYCALC; use Exporter; our @EXPORT = (); our @ISA = qw(Exporter); our @EXPORT_OK = qw(addition multi); our %EXPORT_TAGS = (DEFAULT => [qw(&addition)],Both => [qw(&addition & +multi)]); sub addition { return $_[0] + $_[1]; } sub multi { return $_[0] * $_[1]; } 1; Program: use strict; use warnings; my @list = qw (2 2); use Module qw(:DEFAULT); print addition(@list),"\n"; Above coding is my module MYCALC and the program which using this module, I have not exported any function using @EXPORT, but I have used the DEFAULT in %EXPORT_TAGS with the function addition, when I call this function from the main it says the error as,
Explain goto expr?