in reply to Re: Checking on live site if subroutine exists
in thread Checking on live site if subroutine exists

This subroutine sends an email to a member for one they asked for, like a notice when someone they referred joins, etc.

So, does calling it with an eval or checking if it exists actually execute it?

  • Comment on Re^2: Checking on live site if subroutine exists

Replies are listed 'Best First'.
Re^3: Checking on live site if subroutine exists
by LanX (Saint) on Mar 27, 2021 at 02:42 UTC
    > So, does calling it with an eval

    yes

    > or checking if it exists actually execute it?

    no

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Re^3: Checking on live site if subroutine exists
by perlfan (Parson) on Mar 27, 2021 at 07:05 UTC
    To add to what LanX said, eval effectively hides any errors that might occur when executing what's in the block.

    Since this is a .pl file and require happens at runtime, you may get away with just checking if this file contains some expected characteristics before calling require - like actually existing (or containing some expected text). That said, it's better practice to create an actual Perl module and esure it can be found via @INC (i.e., via PERLLIB, PERL5LIB, or judicious use of FindBin + use lib ....