One of the cool things in perl, to me, is the fact that perl often does what I mean, even if the author of the subroutine didn't intend for it. For example, in the thread "Should Modules Do I/O?", there's a deep question about writing directly to files. One of the solutions is to write to a filehandle. Now, the really pedantic may check that the file handle given actually is a GLOB, or may instead check that it's an IO::Handle. But what if I, instead, created my own object that did something truly funky, and implemented all the functions that you call, which did some other sort of magic to the data? It may not be derived from IO::Handle, but it works just fine!

Or maybe you want to take a callback function. If at all possible, use the $object->$function(@params) syntax for callbacks - this allows an incredible amount of flexibility. I can give you a function name (string), or I can give you a code-ref. And your code will just work... and so will mine.

My point is to be very careful about what you validate. Sometimes you need to validate, but other times you're just getting in the way of the natural, perlish flexibility of your function.


In reply to Re: Testing Edges by Tanktalus
in thread Testing Edges by thekestrel

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.