in reply to Re: how to export a method
in thread how to export a method
You'll need to require Exporter;
Wrong. You can load the Exporter modue at compile time, no need to delay until runtime, i.e. use Exporter instead of require Exporter.
and inherit
Wrong for any perl released since at least 2008. Inheriting from Exporter has side effects that may be unwanted. In particular, it will make Exporter's methods and function appear as methods of the class inheriting from Exporter. Prepare for really strange bugs if the class unintentionally inheriting from Exporter also inherits from another class that has methods with the same name as those inherited from Exporter.
Generally, importing the import() method from Exporer is sufficient and has no unwanted side effects.
See also Exporter in an OO module?, Advice on style.
before your @EXPORT will have any effect.
Wrong. OOP modules should not export methods, as others have explained.
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: how to export a method
by wanna_code_perl (Friar) on Oct 23, 2019 at 07:38 UTC | |
|
Re^3: how to export a method
by toothedsword (Sexton) on Oct 23, 2019 at 00:07 UTC |