Sébastien Aperghis-Tramoni,


  • Have heard Perl coders whine since a couple of years

    • That would be sooo cool if we had relative namespaces

  • More recently, a colleague wanted something similar "because import in Python can do this"

  • Once again, this was a matter of JFDI

  • Load modules with names relative to the current one or from another hierarchy

  • Return the full names of the loaded modules

  • Can create aliases like aliased does (Ovid wanted that)


  • Load a couple of modules

  •     package BigApp::Report;
        use relative qw(Create Publish);
        # loads BigApp::Report::Create, BigApp::Report::Publish
        use relative qw(..::Utils);
        # loads BigApp::Utils
  •     use relative -to => "Enterprise::Framework" => qw(Base Factory);
        # loads Enterprise::Framework::Base, Enterprise::Framework::Factory


  • Using the names returned by import

  •     use relative;
        my ($Maker, $Publisher) = import relative qw(Create Publish);
        my $report    = $Maker->new;
        my $publisher = $Publisher->new;
  •     my ($Base, $Factory) 
            = import relative -to => "Enterprise::Framework"
                                  => qw(Base Factory);
        my $thing = $Factory->new;


  • Using aliases, because make-work-code sucks

  •     use relative -aliased => qw(Create Publish);
        my $report    = Create->new;
        my $publisher = Publish->new;
  •     use relative -to => "Enterprise::Framework",
                     -aliased => qw(Base Factory);
        my $thing = Factory->new;


  • In your CPAN mirror

  • Works on Perl 5.004