Untainting variables that you've already checked to be good? That's the battle you should be fighting because it's a recipe for disaster. Don't wuss out: if you want taint checking, don't subvert it by giving programmers a way to ignore it. :)

The trick to any of these sorts of decisions is to look at the rest of the code and figure out which style it uses, then try to use the same model. If most of the interface changes arguments in place, do that. If most of the interface leaves arguments alone and returns the munged values, do that. Beyond that, figure out which one makes the problem easier to solve and the code easier to read ( the optimal combination of those!), and do that.

Once you figure out what you want, clearly document it.

But, if you're spending all your time worrying about little details like this, you're probably avoiding much bigger problems that you don't want to think about. Put something in place and move on. :)

--
brian d foy <brian@stonehenge.com>

In reply to Re: Writing general code: real world example - and doubts! by brian_d_foy
in thread Writing general code: real world example - and doubts! by polettix

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.