williamlee82 has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone, I am a new PERL user. I have a questions: From my understanding about the OOP and perl module,both are using .pm module, but I just wonder why when I don't using OOP method, I need to do the 'use Exporter' and doing some EXPORT or EXPORT_OK ... in the. pm file but for the OOP, I can save to skip those Export procedure. May I know what is the difference between those 2? Many thanks.

Replies are listed 'Best First'.
Re: OOP and perl module
by Eliya (Vicar) on Feb 27, 2012 at 08:33 UTC

    You only need to use Exporter if you want to export symbols (e.g. subroutines) into the namespace of whoever uses the module.  With OO, you typically access functionality via method calls (which are made from an object instance), so exporting the corresponding subs doesn't make a lot of sense.

Re: OOP and perl module
by Anonymous Monk on Feb 27, 2012 at 15:06 UTC
    Perl's implementation of OOP techniques is somewhat "grafted on to" a language which strictly speaking does not require you to use them. You can therefore use a package as the source of "an object," or as a collection of subroutines (whether or not those subroutines are exported). Instead of the language insisting that you must do things a certain way, "there's more than one way to do it.™"