Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1007355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:36:20+00:00 2026-05-16T08:36:20+00:00

I have a rather complex data structure I’ve implemented in Perl. This has been

  • 0

I have a rather complex data structure I’ve implemented in Perl. This has been broken up into about 20 classes. Basically, any time you want to use one of these classes, you need to use all of them.

Right now, if someone wants to use this data structure, they need to do something like:

use Component::Root;
use Component::Foo;
use Component::Bar;
use Component::Baz;
use Component::Flib;
use Component::Zen;
use Component::Zen::Foo;
use Component::Zen::Bar;
use Component::Zen::Baz;
... # 15 more of these...
use Component::Last;

to be able to manipulate all parts of it. How can I write a module that does this for the user, so all they have to do is

use Component;

to get all of the other modules imported?

In this particular case, the modules are all classes and don’t have exports.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:36:20+00:00Added an answer on May 16, 2026 at 8:36 am

    If these are just classes (i.e. they don’t export any functions or variables when you use them), then all that really matters is that they have been loaded.

    Just create Component.pm:

    package Component;
    
    our $VERSION = '1.00';
    
    use Component::Root;
    use Component::Foo;
    use Component::Bar;
    use Component::Baz;
    use Component::Flib;
    use Component::Zen;
    use Component::Zen::Foo;
    use Component::Zen::Bar;
    use Component::Zen::Baz;
    ... # 15 more of these...
    use Component::Last;
    
    1; # Package return value
    

    You don’t need Exporter or anything like it.

    However, instead of having a module that is nothing but use statements, it probably makes more sense to put those use statements into the class of the root node, or into the module that creates the data structure. That is, people will want to say:

    use Component::Root;
    my $root = Component::Root->new(...);
    

    or

    use Component qw(build_structure);
    my $root = build_structure(...);
    

    depending on how your data structure is normally created. It might be a bit confusing for people to write:

    use Component;
    my $root = Component::Root->new(...);
    

    but it really depends on what your API looks like. If there are a number of classes that people might be calling new on, then use Component might be the way to go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this rather complex query that grabs data from three tables, and now
I have a rather complex data source for my UITableView. I am very carefully
I have an application that loads lots of data into memory (this is because
I have been tasked to write a module for importing data into a client's
I have a button in a rather complex repeater, it has to have UseSubmitBehavior=False
We have a rather large and complex application written in Java which is running
I have a rather large and complex game in C#, and in it are
I have a window that contains several rather complex views. Right now, I'm using
I have a hash table where the keys are rather complex lists, with sublists
I have a number rather large, complex xml documents that I need to loop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.