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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:45:59+00:00 2026-05-11T12:45:59+00:00

I have a Perl project were I just had a problem by making a

  • 0

I have a Perl project were I just had a problem by making a circular package call. The code below demonstrates the problem.

When this is executed, each package will call the other until all of the memory of the computer is consumed and it locks up. I agree that this is a bad design and that circular calls like this should not be made in the design, but my project is sufficiently big that I would like to detect this at run time.

I have read about the weaken function and Data::Structure::Util, but I have not figured out a way to detect if there is a circular package load (I am assume, because a new copy is being made at each iteration and stored in each copy of the $this hash). Any ideas?

use system::one;  my $one = new system::one();   package system::one;  use strict;  use system::two;  sub new {   my ($class) = @_;    my $this = {};     bless($this,$class);    # attributes   $this->{two} = new system::two();   return $this;  }   package system::two;  use strict;  use system::one;  sub new {   my ($class) = @_;    my $this = {};     bless($this,$class);    # attributes   $this->{one} = new system::one();   return $this;  }  
  • 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. 2026-05-11T12:46:00+00:00Added an answer on May 11, 2026 at 12:46 pm

    Here, have some code too. 🙂

    sub break_recursion(;$) {     my $allowed = @_ ? shift : 1;     my @caller = caller(1);     my $call = $caller[3];     my $count = 1;     for(my $ix = 2; @caller = caller($ix); $ix++) {         croak 'found $count levels of recursion into $call'             if $caller[3] eq $call && ++$count > $allowed;     } }  sub check_recursion(;$) {     my $allowed = @_ ? shift : 1;     my @caller = caller(1);     my $call = $caller[3];     my $count = 1;     for(my $ix = 2; @caller = caller($ix); $ix++) {         return 1             if $caller[3] eq $call && ++$count > $allowed;     }     return 0; } 

    These are called like:

    break_recursion(); # to die on any recursion break_recursion(5); # to allow up to 5 levels of recursion my $recursing = check_recursion(); # to check for any recursion my $recursing = check_recursion(10); # to check to see if we have more than 10 levels of recursion. 

    Might CPAN these, I think. If anyone has any thoughts about that, please share.

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

Sidebar

Related Questions

I have this web based project written in Perl and I have to migrate
I have learned Perl and PHP.So I want to do simple real time project
I have inherited a web project that is perl based and I'm attempting to
I have some Perl code that executes a shell script for multiple parameters, to
I have a Perl script, that's supposed to match this string: Sometimes, he says
I have a Perl script which nests foreach loops as seen below. It takes
I am working on a project(I have to implement it in Perl but I
I'm re-acquainting myself with Perl, and have just used module-starter to initialise a new
I have lots of strings in a text file, like this: /home/mossen/Desktop/jeff's project/Results/FCCY.png /tmp/accept/FLWS14UU.png
We are factoring out the common code from our Perl project. One main program

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.