Those are prototypes, documented in perlsub. They are used reduce code clutter and mimic the behavior of builtins by changing how the compiler parses subroutine calls.
Most Perl programmers new to prototypes instantly assume they're like other languages' prototypes, i.e. they are for declaring how many and what type of parameters a function expects. This is a misuse of them, as it generally causes problems and is quite often bypassed entirely anyways. See FMTEYEWTK about Prototypes. The article was long ago removed from O'Reilly's site, but it still remains relevant. | [reply] |
If Tom Christiansen's article indicated above hasn't convinced you, there is a somewhat shortened form of what it is saying in Damian Conway's "Perl Best Practices":
Don't use subroutine prototypes
Now, if that isn't clear enough.. :)
Chapter 9 of the PBP book, "Subroutines", has a section "9.10 Prototypes"; I think the book in it's entirety is worthwhile reading (actually, having it handy) if you enjoy doing things with Perl.
Good luck with those not-quite-friendly prototypes.
| [reply] |
Your code contains prototypes. These allow
- function calls to be written with fewer parentheses, in some cases, and with a strong possibility of a loss of readability.
- function calls with fewer backslashes.
| [reply] |
Using prototypes force you to explicitly write each param instead of passing list containing correct params to subroutine... :-(
| [reply] |