I have a try catch block in perl
try {
//statement 1
//statement 2
};
catch Error with
{
print "Error\n";
}
When I run the perl program I get the following error
Can’t Call method “try” without a package or object reference at…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Perl does not provide
tryorcatchkeywords. To trap “exceptions” thrown bydie, you can set a$SIG{__DIE__}handler or useeval. Block form is preferred over string form, as parsing happens once at compile time.There are various modules that provide more traditional
try-like functionality, such asTry::Tiny.