This late in the thread, no one will probably see this, but...

I've seen several places here that have confused using prototypes with predeclaring subroutines. As I note in (tye)Re: A question of style, predeclaring your subroutines allows you to catch typos in subroutine names at compile time but only if you don't use parens when you call your subroutines. This can be a big win in some cases.

Prototypes can be used to catch other types of mistakes at compile time but the consesus is that they aren't very good at that and come with significant other problems that make their use for that purpose rarely (if ever) desirable. It is easier to make a case for using prototypes to create constant subroutines or to allow the use of bare code blocks in things that you want to have an interface similar to grep and map.

You can also use prototypes to cause arguments to be passed by reference rather than by "alias" (which looks like "passing by value" unless you modify elements of @_ directly) but many consider this a bad idea, me among them.

        - tye (but my friends call me "Tye")

In reply to (tye)Re: Declaring Subroutines by tye
in thread Declaring Subroutines by the_0ne

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.