in reply to Same function multiples unknown modules
The usual way to have several implementations of a function is to place them in a package namespace. If the modules furnish an object constructor, calling the runonce() method will automatically select the correct one.
To call a non-method runonce() from a package, use the fully-qualified name,
To call once for each package loaded, you'll need to go through all the loaded packages and try each. Here's an unsophisticated way to do it,Package::Name::runonce();
The eval is used to trap fatal errors from packages which don't define runonce().for (keys %INC) { s!/!::!g; s/\.pm$//; eval { $_::runonce() }; }
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Same function multiples unknown modules
by Delusional (Beadle) on Sep 19, 2005 at 13:59 UTC | |
by Zaxo (Archbishop) on Sep 19, 2005 at 23:46 UTC | |
by Delusional (Beadle) on Sep 26, 2005 at 09:56 UTC |