Custom Function Scope and Variable Lifetime

Blatter, Nicholas drnick at physics.byu.edu
Wed Aug 5 22:32:34 IST 2009


I have been working with writing custom function for MailScanner and have come across an issue with variables and subroutines in one custom function (module) stepping on those in another module.   I'm not terribly familiar with Perl, but I imagine this is a result of MailScanner loading all the modules into a single namespace/package/scope.

Does this sound correct?  When writing custom functions, is there anything you can do to keep the functions separate from each other so that you don't run into name collisions or other problems arising from a shared namespace?  Would it work (or even make sense) to have each custom function in it's own Perl package?  How would that work when telling MailScanner to load the function?

I'm also wondering what the lifetime of 'global' variables (in the custom function module) looks like.  Is there just one instance of each module loaded for MailScanner or does each MailScanner child process load an instance of each module (this appears to be the case from watching the logs). Are the global variables in each module shared between the MailScanner children processes or are they separate?

Sorry for the noobish questions but I'd like to make sure I'm writing these modules for MailScanner as well as I can.  Any tips or suggestions on their organization are appreciated.

Thanks for your time,

Nick


More information about the MailScanner mailing list