Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Checking on live site if subroutine exists

by tobyink (Canon)
on Mar 30, 2021 at 11:01 UTC ( #11130583=note: print w/replies, xml ) Need Help??

in reply to Checking on live site if subroutine exists

Just a minor comment about this pattern:

my $_tsub = "SendMultiPartMemberEmailMimeLiteSendGrid"; if(exists &{$_tsub}) { # code to call it } else { require "/path/to/the/file/SendMultiPartMemberEmailMimeLiteSen"; # code to call it }

Your code to call it is unnecessarily duplicated. Better:

my $_tsub = "SendMultiPartMemberEmailMimeLiteSendGrid"; if ( not exists &{$_tsub} ) { require "/path/to/the/file/SendMultiPartMemberEmailMimeLiteSen"; } # code to call it

But this can probably be even better written as:

require "/path/to/the/file/SendMultiPartMemberEmailMimeLiteSendGri"; # code to call it

Because require is smart enough to not load the same file twice.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11130583]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2021-10-26 20:56 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (90 votes). Check out past polls.