Hi! Please consider following me on twitter: @hanekomu.

Exporter::Simple

Here is another module using attributes to simplify an API and hide implementation details. This time it's Exporter's API. Exporter::Simple, when used by a package, allows that package to define exports in a more concise way than using Exporter. Instead of having to worry what goes in @EXPORT, @EXPORT_OK and %EXPORT_TAGS, you can use two attributes to define exporter behavior:

my @bar : Exportable(vars) = (2, 3, 5, 7);
my $foo : Exported(vars) = 42;
my %baz : Exported = (a => 65, b => 66);

sub hello : Exported(greet,uk) { "hello there" }
sub askme : Exportable { "what you will" }
sub hi    : Exportable(greet,us) { "hi there" }

You get the idea. I wasn't sure whether to emulate attributes for globals as well, but seeing that they're going to be in perl 5.8.0, I'm going to wait until that's out before revising Exporter::Simple for a clean solution.

Enjoy. Feedback, as always, is welcome.

Write a comment | Bookmark and Share

posted at: 15:17 | path: /dev | permalink | 0 comments | 0 trackbacks

Comments are closed for this story.

Trackbacks are closed for this story.