Exporting functions by attributes
tjc at wintrmute.net
Tue Oct 9 13:47:48 BST 2007
Yuval Kogman wrote:
> It breaks with require, since INIT/CHECK only fire at real startup.
> Also, it pollutes UNIVERSAL.
Ah, a pity. It did seem like a more natural way for the language to
indicate what to export. Maybe in perl6, eh? :)
> On Tue, Oct 09, 2007 at 14:59:07 +1000, Toby Corkindale wrote:
>> It occurred to me earlier that exporting functions from modules in the
>> traditional way, ie. as given in `perldoc Exporter`, seems poor,
>> especially with the availability of function attributes in recent
>> versions of Perl.
>> I had a search around on CPAN, and found that there are already at least
>> seven different Exporter variants - Classic, Easy, Easiest, Lite,
>> NoWork, Simple and Tidy. (There are probably more, but I stopped looking
>> at this point).
>> For the record, Exporter::Simple does what I had in mind - you can tag
>> functions with attributes Exported or Exportable (exported by default or
>> optionally). More info in their docs.
>> I thought I'd pass this along as I found it interesting.
>> It won't work on older pre-attribute versions of Perl of course.
More information about the london.pm