in reply to What's the better Perl style? Define parameters or not?

As already noted, these "parameter specifications" are called "prototypes", but they have absolutely nothing to do with function prototypes in C. They are also generally best avoided.

If you want something similar to C's function prototypes (parameter type/number checking, plus support for optional and/or named parameters), take a look at Devel::Declare for the general case or MooseX::Declare if you're doing Moose-based OO.

  • Comment on Re: What's the better Perl style? Define parameters or not?

Replies are listed 'Best First'.
Re^2: What's the better Perl style? Define parameters or not?
by pureHeart (Acolyte) on Jan 05, 2010 at 15:12 UTC
    I really appreciate all of you who provided comments. Your replies opened my eyes. Thank you.
      You may also want to look at Params::Validate and signatures if you're not doing OO programing. There are others on CPAN but these two spring to mind.


      Smoothie, smoothie, hundre prosent naturlig!