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

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

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
    Wrong. ...
    Wrong. ...
    Wrong. ...
    there are no sweeter words than "I told you so". ;-)

    Yeah, I'm starting to see that about you :-)

    Points well taken about require vs. use, and @ISA. The very first example in the Synopsis has long done what I need it to do. Maybe it's time for a documentation patch to de-emphasize the older calling convention? No reason for it to have top billing if it's not recommended for new code. Anyway, I'll definitely be adopting this advice going forward. Thanks.

    OOP modules should not export methods, as others have explained.

    Yes, I was the first to explain that, some hours before your reply.

Re^3: how to export a method
by toothedsword (Sexton) on Oct 23, 2019 at 00:07 UTC
    Thank you for you help. I will try it.