Rules and standards are unlikely to be helpful unless you first establish why people have been putting main loops inside of modules. If you outlaw a legitimate practice, your programmers will jump through hoops to get things done and things may end up even more of a mess than they were before.

You might benefit from consolidating main loop processing into a single "main loop management module". On the other hand, you may have some very good reasons for needing separate ways of handling the main loop portion of a program. Placing the main loop of a program in a module separate from the launch script is a well established programming practice, especially if the action of the main loop is complex and needs lots of supporting functions. Only your team (or close analysis of the code) can answer that question.

I'd also take a careful look at how your code is factored into modules. It is usually a good idea to keep main loop code in a separate module from general purpose code. People may have lots of reasons to use that super-duper-string-muncher subroutine, but if super-duper-string-muncher is sitting in a module with an event loop, only programs that need both string-muncher and that particular event loop can use it safely. Perhaps a rule that "main loops" need to be in a separate specially named module (OurCompany::MainLoop::AppNameHere for example) would solve the problem better than an arbitrary limit on the number of main loops.

Best, beth


In reply to Re: MainLoop in Perl Module by ELISHEVA
in thread MainLoop in Perl Module by wjmarlett

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.