I'm a big fan of simplifying the writing (and thus to some degree the maintenance) of code. For me, that translates to a module specifically designed to handle the configuration and decision aspects of debugging tack-ons. No point, in my mind, of cluttering the calling sequence with extra parameters not related directly to the function performed by the method/subroutine in question.

The same logic went for a generic output module to handle variable and uncertain output environments (writing to console, writing to a web page as part of CGI response, writing to a printer, etc.). A special module handles all the configuration and execution details; no special parameters to invoke the work routines of my programs, but when I call the output function it translates, encapsulates, and otherwise transmogrifies the data and puts it out the correct doorway.

As noted by others, it's still a global-thinking approach, but it doesn't pollute main::namespace, and the modification of its attributes requires a bit more intentional effort than accidentally setting the wrong variable. These are the evils of global variables, and they are avoided by shoving the global function off into its own module.


In reply to Re: Best Practice: How do I pass option parameters to functions? by marinersk
in thread Best Practice: How do I pass option parameters to functions? by An_Idea_Within

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.