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

Ask A Question

Stats

  • Questions 81k
  • Answers 81k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The problem with putting non Java (or other languages) files… May 11, 2026 at 4:27 pm
  • Editorial Team
    Editorial Team added an answer Can you try manually redirecting stderr? FILE* stderr_redirect = freopen(… May 11, 2026 at 4:27 pm
  • Editorial Team
    Editorial Team added an answer from http://developer.apple.com/iPhone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/WindowsandViews/WindowsandViews.html One thing that experienced Mac OS X developers… May 11, 2026 at 4:27 pm

Related Questions

I've searched the web a bit, but all I found were abandoned projects and
I've been benchmarking the performance of a framework I'm writing in Perl and I'm
I'm seeking a javascript history framework to handle navigation inside a page when the
Suppose there were several projects mostly maintained by smart interns, who eventually leave after

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.