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

  • SEARCH
  • Home
  • 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 7492585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:28:20+00:00 2026-05-29T16:28:20+00:00

I did a little searching first but haven’t found a satisfactory answer yet (my

  • 0

I did a little searching first but haven’t found a satisfactory answer yet (my apologies if this is a repeat question — or worse, a stupid question)…

Do dynamically loaded Perl modules such as those included with the answer to this question (relevant code replicated below) get properly cached by mod_perl for future usage?

my $module = 'My::Module';

eval {
    (my $file = $module) =~ s|::|/|g;
    require $file . '.pm';
    $module->import();
    1;
} or do {
    my $error = $@;
    # ...
};

In the above example, will “My::Module” be cached by mod_perl after this invocation for future usage if a subroutine similarly tries to require it in the future (at least in whatever manner mod_perl generally uses for package caching)?

Hopefully that question is somewhat clear, please let me know if any clarification is needed. Thanks.

  • 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-29T16:28:21+00:00Added an answer on May 29, 2026 at 4:28 pm

    Yes, it will be cached by perl itself. (mod_perl’s task concerning this topic is only to translate scripts into cachable packages and take care to keep a Perl running the whole time instead of exiting when a response is finished.)

    You must understand, though, how this plays out in the various httpd MPMs. Mind that processes have independent %INC. With prefork, the following example program will need to dynamically load the module for each fresh child. This means the first couple of requests will be slower than average because they are handled round-robin. The module is cached until the child exits because it has reached its max requests threshold, then each new child has to load again.

    package Foo;
    use Apache2::Const -compile => qw(OK);
    use Apache2::RequestIO qw();
    use Apache2::RequestRec qw();
    use Data::Dumper qw(Dumper);
    
    sub handler {
        my ($r) = @_;
    
        $r->content_type('text/plain');
        $Data::Dumper::Sortkeys = 1;
        $r->print(Dumper \%INC);
    
        my $module = 'Template';
        eval {
            (my $file = $module) =~ s|::|/|g;
            require $file . '.pm';
            $module->import();
            1;
        } or die $@;
    
        $r->print(Dumper \%INC);
        return Apache2::Const::OK;
    }
    
    1;
    

    It is generally recommended to optimise for performance by loading any module you could possibly need already at server start-up before forking takes place. The server hardware should have enough memory to make the module lazy-loading trade-off unnecessary.

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

Sidebar

Related Questions

I'm searching the Apple documentation to try to answer this question, but without success.
I did some searching for this, but it's a little too generic to pull
Sorry if this was already answered before. I did a little searching and found
Did some searches here & on the 'net and haven't found a good answer
Got a partial answer from searching in this thread: Viewing raw RSS feed? But
I did a little bit of Web Programming here and there but I never
I have a little problem. i searched but did not get help to solve
This is just one of those little things I did all the time in
Hopefully this is a pretty simple question for someone to answer. I have a
I did some little experimentation on this. I created an boolean attribute, named isFault.

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.