in reply to Module callbacks - to fork or not fork

I stumbled reading the code fragment and had to consult the manuals (thanks for that). Are there any benefits of 'defined &$maybe_coderef' syntax (over exists or 'CODE' eq ref... or TIMTOWTDI-others)? It triggers 'uninitialized' warning for uninitialized value, but maybe there are not obvious benefits?

Replies are listed 'Best First'.
Re^2: Module callbacks - to fork or not fork
by hippo (Archbishop) on Mar 01, 2023 at 10:27 UTC
    TIMTOWTDI-others

    With Ref::Util you can test it safely, quickly and all-in-one with is_coderef ($maybe_coderef). If you have not already looked at Ref::Util I can wholeheartedly recommend it. Your code will be shorter, less error-prone, faster and arguably more readable/maintainable with it.


    🦛

      If you have not already looked at Ref::Util I can wholeheartedly recommend it

      But Ref::Util is not core...

        G'day Bod,

        "But Ref::Util is not core..."

        You should probably expand on that; as it stands, it's not making a lot of sense to me. This is the first instance of the word "core" in the entire thread. The code you've posted on this site often uses non-core modules: Template, DBI, and many others.

        — Ken