Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^6: Perl Modules

by tobyink (Canon)
on Jun 21, 2017 at 18:45 UTC ( [id://1193229]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Perl Modules
in thread Perl Modules

Cycles in use statements can cause issues. Often hard-to-diagnose problems.

Breaking the cycle by making one of them a just-in-time require instead of a use is often a good solution.

# AAA.pm package AAA; use base 'Exporter'; our @EXPORT = qw(aaa); use BBB qw(bbb); sub aaa { my $arg = shift; return 0 if $arg <= 0; return 1 + bbb($arg - 1); } 1; # BBB.pm package BBB; use base 'Exporter'; our @EXPORT = qw(bbb); # use AAA qw(aaa); sub bbb { my $arg = shift; return 0 if $arg <= 0; require AAA; return 1 + AAA::aaa($arg - 1); } 1; # main.pl use AAA; use BBB; print aaa(3) + bbb(4), "\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1193229]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-19 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found