Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • by Alias (5735) on 2008.01.24 20:59 (#60497) Homepage Journal
    * Is there an existing module that works and does what I want?

    Probably not, exporting is such a fundamental task that Export modules tend to be relatively back-compatible, and as such don't use attributes.

    * If not, can Exporter::Simple be fixed?

    If it involves changing it's Perl minimum version, no.

    * If not, could you write an Export-by-attribute system that does work?

    Quite probably.

    I mean, it's just a case of a "use Attribute::Export;" setting the module to @ISA Exporter, creating the @EXPORT variable, and then having the attibute handler append the name to @EXPORT/@EXPORT_OK.

    * If not, could you write something that allows the export information to be conveniently placed near the subroutine?

    You mean like...

    push @EXPORT, qw{function};
    sub function {

    }

    If you aren't using attributes, you might as well just do that.

    But I'd go down the attribute route.

    Just beware you lose 5.6 support that way, so make sure that doesn't matter.
    • I think Adam's solution (push onto @EXPORT) is pretty nice and simple, as far as things that deal with attributes can be. It's exactly what I would've suggested, although I probably would've built atop Sub::Exporter. ;)

      I'll be interested to hear/see what you end up doing.
      --
      rjbs