in reply to Re: RSS Parsing not working on new machine
in thread RSS Parsing not working on new machine

Depending on your Perl version, native try { ... } catch  { ... } finally { ... } blocks may already be available. Perl 5.34 introduced try ... catch. So maybe you want to use that over Try.

Alternatively, there is the more weathered Try::Tiny, which also gives you a try/catch pair.

Replies are listed 'Best First'.
Re^3: RSS Parsing not working on new machine
by wintermute115 (Acolyte) on Apr 15, 2025 at 18:29 UTC

    It looks like the builtin try is getting depreciated, so I'm not keen on using it long term. Having said that, swapping in use experimental 'try'; works (for most feeds; see above). Swapping in Try::Tiny gives me this new error:

    syntax error at /home/ross/scripts/podcasts/podcasts.pl line 233, near + ") {" Execution of /home/ross/scripts/podcasts/podcasts.pl aborted due to co +mpilation errors.

    This is the section it's complaining about:

    try { $curl->pushopt(CURLOPT_HTTPHEADER, [$ua_string]); $curl->setopt(CURLOPT_PROGRESSFUNCTION, \&no_progress); $curl->setopt(CURLOPT_NOPROGRESS, 0); $curl->setopt(CURLOPT_FOLLOWLOCATION, 1); $curl->setopt(CURLOPT_CONNECT_ONLY, 0); $curl->setopt(CURLOPT_URL, $feedsrc); $curl->setopt(CURLOPT_WRITEDATA, \$feed); $curl->perform(); } catch { $broken = 1; #putting next in here complains that it's exi +ting a subroutine } if (!defined($feed)) { # <--- Line 233 $broken = 2; }

    I can't see an error there, and it doesn't throw one without Try::Tiny, so that seems pretty weird.

    EDIT

    OK, I figured that out. The Try::Tiny try/catch blocks need a closing semicolon. So now I have a robust try that won't go away in future versions of perl, and isn't somehow messing up all the feeds, but some are still getting messed up in ways I don't understand.

      It looks like the builtin try is getting depreciated

      The word is deprecated. But what gives you that idea? It just stopped being experimental in the latest version (5.40), so why do you think it's going to be deprecated in the next one?

        I was sure I had a reference that said it was being deprecated (IIRC in 5.40), but now I can't find anything that looks similar so I have no idea if I just made it up. Sorry.

      a try{}catch{}; block needs a semicolon at the end!. It's not a block I guess. FYI, I have tried all of these and I ended up with plain old eval(). I can not be sure of the reasons now. But surely I went this routine a few times.