[Melbourne-pm] Invalid use of Exporter as a parent of a class

Jacinta Richardson jarich at perltraining.com.au
Wed Nov 28 19:05:54 PST 2012


On 28/11/12 19:22, Scott Penrose wrote:
> I prefer the second method of Exporter
>
>           package YourModule;
>           require Exporter;
>           @ISA = qw(Exporter);
>           @EXPORT_OK = qw(munge frobnicate);  # symbols to export on request
>
>         or
>
>           package YourModule;
>           use Exporter 'import'; # gives you Exporter's import() method directly
>           @EXPORT_OK = qw(munge frobnicate);  # symbols to export on request
>
> So instead of inheriting Export, you just create an 'import' sub that is used to do the 'importing'.
>
> Especially if you are doing mixed modules.
>
> Slight disagreement with the others on the list about having both, in that we often create a module like 'use CGI' which can be both an object (if you don't export anything) or import methods.

Not sure who the "we" is who often create modules like CGI. Personally I 
think that CGI is in error, and that modules that should blur the lines 
between OO and imperative use are few and far between.  But otherwise 
this is a workable alternative.

All the best,

     Jacinta


More information about the Melbourne-pm mailing list