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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:38:12+00:00 2026-06-10T16:38:12+00:00

I run across this problem every once in a while. For some reason I

  • 0

I run across this problem every once in a while. For some reason I get the “Undefined subroutine” error when trying to call an exported sub, and I have no idea why since it seems to happen out of the blue, in mature code.

The last time it happened I think I resorted to using something like “package_2::exported_sub().” That worked this time, but it simply returned an error for another sub in package_2. Even putting “use package_2;” in the line above doesn’t help! The only thing I can think of is that the exported sub is being undefined somehow.

My code looks a little like this:

in file package_1.pm:

package package_1;

require Exporter;
@ISA = qw( Exporter );

@EXPORT = qw(
local_sub
);

use package_2;
use strict;
use warnings;
use diagnostics;

sub local_sub {
  &exported_sub;
}

in file package_2.pm:

package package_2;

require Exporter;
@ISA = qw( Exporter );

@EXPORT = qw(
exported_sub
);

use strict;
use warnings;
use diagnostics;

sub exported_sub {
 # do something
}

I’m at my wit’s end…I was working on an unrelated hot ticket when this popped up, and user testing starts tomorrow!

Thanks in advance!


Update:

ikegami, thanks for your fix! I’m curious, though. I ran across this again, but this time I never did find the circular dependency. I narrowed it down to one line:

$row->{$attr} = ' ' unless ( $row->{$attr} );

Obviously, the line has nothing to do with using or requiring at all! I’ve looked in the Apache logs but nothing really seems to stand out, but will work to resolve whatever I find. I’ll also see if I can get more warnings.

Aside from that, what do you recommend as a next step?

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-06-10T16:38:13+00:00Added an answer on June 10, 2026 at 4:38 pm

    I suspect you have a circular dependency: package_1 uses package_2 and package_2 uses package1 (directly or indirectly).

    What follows is a solution I originally published on PerlMonks: http://www.perlmonks.org/?node_id=778639


    [ The need to use this technique is a very strong indicator of a design flaw in your system, but I recognize that the resources are not always available to fix design flaws. ]

    If ModA uses ModB, ModB uses ModA, and ModA or ModB imports symbols from the other, one needs to pay attention to code execution order. The best way I’ve found to avoid problems is to setup Exporter before loading any other module.

    ModA.pm:

    package ModA;
    
    use strict;
    use warnings;
    
    BEGIN {
       our @ISA = qw( Exporter );
       our @EXPORT_OK = qw( ... );
       require Exporter;
    }
    
    use This;
    use ModB;
    use That;
    
    ...
    
    1;
    

    ModB.pm:

    package ModB;
    
    use strict;
    use warnings;
    
    BEGIN {
       our @ISA = qw( Exporter );
       our @EXPORT_OK = qw( ... );
       require Exporter;
    }
    
    use This;
    use ModA;
    use That;
    
    ...
    
    1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a GUI in Scala, and I've run across a strange problem while
One of the patterns that I frequently run across when developing is trying to
I'm working on an EntityFramework application and I have run across a problem when
I'm working on writing a Pong game and I've run across a problem. I'm
While building several different projects in QtCreator, I have run across the following build
I am trying to run some tests using OPENmpi processing data in an array
This is a resource-allocation problem. My goal is to run a query to fetch
Every time I try to build, I get the error: CMake Error: The source
I am trying to follow along Michael Hartl's Rails tutorial but I've run across
I ran across this problem, which has been driving me nuts. In a nutshell,

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.