Which way is the common practice in Perl world?
The fast majority of code I see doesn't use prototypes, so not using prototypes is "common practice". But there's also a lot of code out there that doesn't use warnings or strict, so I wouldn't go by "common practice".

I won't recommend what you should do. I think you make yourself familiar with the pros and cons and make a decision what to use yourself - I think that's far more useful than making a tally of the responses and just follow the majority.

I will tell you why I don't use the $$$ prototype. Without prototypes, the following sub calls are equivalent:

sub foo {...}; my @a = (1, 2, 3); foo(1, 2, 3); foo(@a);
With prototypes, the second is an error:
sub bar ($$$) {...}; my @a = (1, 2, 3); bar(1, 2, 3); bar(@a); # Not enough arguments error
I find the non-flatting behaviour far more annoying than the benefit of the prototype checking the number of arguments.

That isn't to say I never use prototypes. A few prototypes have their benefits, IMO. They are: the empty prototype, the $ and _ prototypes (but only if it's just $ or _, nothing else with it), and prototypes starting with one or more &, \@ or \%, optionally followed by ;@. You need those prototypes to mimic calling conventions of certain build-ins. (Functions like lc, push and grep for instance).


In reply to Re: What's the better Perl style? Define parameters or not? by JavaFan
in thread What's the better Perl style? Define parameters or not? by pureHeart

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.