Slash Boxes
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.
More | Login | Reply
Loading... please wait.
  • * 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
    • 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.
  • If in fact your module simply needs to "export a huge pile of sim_* functions", then one solution would be to write your own import() sub that scans your package's symbol table hash and exports every sub with a name that matches /^sim_/.

  • I'm the author of Exporter::Simple. It has some other bugs as well, and there's, like you said, no simple fix. Maybe Damian's Perl6::Export does what you want? The only thing - as far as I can remember - that Exporter::Simple does additionally is to be able to export variables, which Damian says is evil anyway. If Perl6::Export works better, then I was planning to deprecate Exporter::Simple.

  • Well to start with, please please please make sure it's based on Sub::Exporter and not And as for basing it on attributes, I don't think that is a plus. Attributes are poorly implemented with a poor API to use them. They give you just enough power to think you can do something cool with them, and then fall short (IMO at least).

    Okay, that said, here is a modified version of a proof of concept [] module I did recently that mixed Moose roles and Sub::Exporter. It should do the trick for exporting

  • use export bar => sub {...};

    What I haven't figured out yet is how to get an automatic unimport() call without userland $^H.

    I'm convinced that it shouldn't involve Attribute::Handlers or anything else messing with UNIVERSAL::* (or @UNIVERSAL::ISA, eek!) and/or inheritance (certainly not inheritance of

    It could use attributes, probably by injecting compile-time MODIFY_type_ATTRIBUTES methods into your package, but it looks like something like 'no Exporter::NoReally' would be required to finish