Exporter::Attributes - Export symbols by attributes


version 0.002


    package FooBar;

    use Exporter::Attributes qw(import);

    sub Foo : Exported;
    sub Bar : Exportable;

    our $Cat : Exportable(vars);
    our $Dog : Exportable(vars);

    package main;

    use FooBar;           # import &Foo
    use FooBar qw(Bar);   # import &Bar
    use FooBar qw(:vars); # import $Cat and $Dog
    use FooBar qw(:all);  # import &Foo, &Bar, $Cat and $Dog


This module is inspired by Exporter::Simple, but this module is broken since a long time. The new implementation uses a smarter way, by rewriting the caller's symbol table and then goto "import" in Exporter.

The list of the export symbols are captured with attributes. There are two attributes:

  • Exported

    Which adds the name of the symbol to @EXPORT

  • Exportable

    Which adds the name of the symbol to EXPORT_OK

The attributes accepts a list of tags as argument.



This is an ambivalent function. When called as Export::Attributes->import it just imports this "import" function into the namespace of the caller.

When called from any other class, it rewrites @EXPORT, @EXPORT_OK and @EXPORT_TAGS and let the rest of the work do by Exporter.

For overloading the import function, use this template:

    sub import {
        # do some stuff, let @_ untouched
        goto &Exporter::Attributes::import;


The tests in this distribution are copied from Exporter::Simple.


Please report any bugs or feature requests on the bugtracker website

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.


  • David Zurborg <>

  • Marcel Gruenauer <>


This software is Copyright (c) 2015 by David Zurborg.

This is free software, licensed under:

  The ISC License