|Don't ask to ask, just ask|
See if a certain package has a certain sub, without executing that subby muba (Priest)
|on Mar 20, 2004 at 15:03 UTC||Need Help??|
muba has asked for the
wisdom of the Perl Monks concerning the following question:
I am writing a simple plugin system. I'm not sure whether I'm going to use it, but it's more like a way to explore Perl.
So, I have an array which contains packages names. Those packages should have a sub 'ReceiveMessage'.
A package called Communications contains a sub 'SendMessage'.
This SendMessage loops over the array to check which packages do have a ReceiveMessage and send a message to it. Currently, the array consists of one item: "Communications".
Of course I call the SendMessage sub once: &Communications::SendMessage("Hello, World!");
The strange thing is, I get output like I called SendMessage twice:
It appears to me that ReceiveMessage is not only called when the message is sent, but also when SendMessage checks it's existance. How can I prevent this?
Update: just clarified the last paragraph a little
Update: removed line of code which was coded in a inconsistent style and only was there for debug purposes :)