Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

try/catch issue

by perlancar (Hermit)
on Jun 29, 2021 at 03:21 UTC ( [id://11134415]=perlquestion: print w/replies, xml ) Need Help??

perlancar has asked for the wisdom of the Perl Monks concerning the following question:

I cannot seem to get try/catch to work without Feature::Compat::Try or Syntax::Keyword::Try on perl 5.34.0, any idea what I'm doing wrong?

#!/usr/bin/env perl

use feature "try";
no experimental "try";

try {
    die "woah";
} catch ($err) {
    print "blah\n";
}

results in "Syntax error at ... line 8, near ) {", while this works:

use Feature::Compat::Try;

try {
    die "woah";
} catch ($err) {
    print "blah\n";
}

as well as this:

use Syntax::Keyword::Try;

try {
    die "woah";
} catch ($err) {
    print "blah\n";
}

Replies are listed 'Best First'.
Re: try/catch issue
by haukex (Archbishop) on Jun 29, 2021 at 04:00 UTC

    no experimental "try"; turns the try feature back off. You probably meant either use feature "try"; no warnings "experimental::try"; or use experimental "try";. See also feature and experimental.

      D'oh. It's been a while since I use experimental.pm (back in the days using smartmatching). Thanks!
Re: try/catch issue
by Anonymous Monk on Jun 29, 2021 at 16:03 UTC

    /s/woah/whoa/g;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11134415]
Approved by GrandFather
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-25 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found