The difference is purely superficial, AFAIK. The sub() operator within Perl is subject to most of the same rules as the rest. That being said, parentheses are largely optional and are there for readability and grouping purposes only.

Consider these two declarations:

sub foo () { ... } sub bar { ... }

To Perl, they are broken up into the following 'chunks':


What Perl is then doing is substituting defaults for missing chunks. In the PROTOTYPE chunk, where you have a null value in the bar subroutine, essentially, you can think of it as substituting the empty list as the foo subroutine has. (Really, though, it may be doing something quite different, and likely is- I have no idea what Perl does under the covers- yet. ;)

It's just as the calls to print that you make in your code could just as easily have been written:
print ($_[0]);
instead of without the parenthesis. The interpreter is usually very good about guessing at what you really mean.

So, if you use a prototype as part of the subroutine, you'll need the parentheses to group the prototype together. Declaring a subroutine with no prototype is, essentially, the exact same thing as declaring it with an empty list, "( )", for the prototype.

Hope this helps!

--jwest

-><- -><- -><- -><- -><-
All things are Perfect
    To every last Flaw
    And bound in accord
         With Eris's Law
 - HBT; The Book of Advice, 1:7

In reply to Re: mod_perl and function declrations by jwest
in thread mod_perl and function declrations by one4k4

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.