Aha. You're not talking about prototyping at all. You're talking about forward declarations. (See also: prototypes don't do what people expect them to do).

A prototype in perl can be specified at a subroutine declaration to indicate special handling of parameters.

A forward declaration is just there to signal to the compiler that a given name is a subroutine that will be defined later: update: the following code does not use prototypes

#!/usr/bin/perl -w use strict; sub bla; # a forward declaration bla; # <--- call the bla routine sub bla { print "Bla!\n"; }
If bla is not declared at the <----- point the bareword "bla" will be interpreted as a STRING. That's almost never what you want and that's why strict complains if you comment out the forward declaration.

Note that you can still call bla as bla() without needing to declare sub bla beforehand.

Prototypes are not really related to this, except that in order for them to work they must also be known to the compiler before it compiles the first call, so you can also use them in forward declarations.


In reply to Re^5: subroutine prototypes still bad? by Joost
in thread subroutine prototypes still bad? by Anonymous Monk

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.