Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Checking on live site if subroutine exists

by tobyink (Canon)
on Mar 30, 2021 at 11:01 UTC ( [id://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 +dGrid.pl"; # 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 +dGrid.pl"; } # code to call it

But this can probably be even better written as:

require "/path/to/the/file/SendMultiPartMemberEmailMimeLiteSendGri +d.pl"; # code to call it

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-03-29 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found