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 7684811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:06:47+00:00 2026-05-31T19:06:47+00:00

I have been toying with the modulino perl pattern and would like to load

  • 0

I have been toying with the modulino perl pattern and would like to load one without knowing the package name and only the file in which it is. I’m looking for something that could be used like this:

eval {
  my $file = "some-file-name-in-the-hierarchy-unrelated-to-package-name";
  my $module = something($file);
  $module->sub1();
};

The something here is the key. No require or use since I would need the module name afterwards. Do I have to read the $file and parse the package name out of it to then use it? There might a better way I’m sure. There always is in perl.

  • 1 1 Answer
  • 0 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-31T19:06:48+00:00Added an answer on May 31, 2026 at 7:06 pm

    Which of the files do you control? If you are creating the program as a modulino and then trying to load that file, just make the last statement in the file return the package name. require expects you to return a true value and most modules use 1;. However, you can use any true value you like. This will be the return value of require:

    # i_dont_know_whats_inside
    package Buster;
    
    __PACKAGE__;
    

    Loading it is easy:

    my $package = require 'i_dont_know_whats_inside';
    
    print "Package is $package\n";
    
    $package->new( ... );
    

    If you can’t control the file you’re loading, it’s not that hard to find out what’s inside:

    my @packages = load_file( 'i_dont_know_whats_inside' );
    
    print "Packages are @packages\n";
    
    sub load_file {
        my $file = shift;
        require Module::Extract::Namespaces;
        my @packages = Module::Extract::Namespaces->from_file( $file );
        my $rc = require $file;
        return @packages;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So lately I have been toying around with how Mathematica's pattern matching and term
Alright, so I've been toying around with the Steam Web API, I have one
I have a scenario that I haven't been able to solve: I'm toying around
I have been trying to explain the difference between switch statements and pattern matching(F#)
I have been toying with http authentication using the .htaccess file in an attempt
I have been toying with some codes to solve this using a Levenberg-Marquardt solver
I have been toying with this piece of code: QGraphicsLineItem * anotherLine = this->addLine(50,50,
I have been toying with an example hpp provided in the boost library and
I'm fairly new to Android and have been toying around with Canvas. I'm attempting
I've been toying with c++ for a little while, and coming from java one

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.