in reply to Embracing functions with parentheses
For user-defined functions, I always use parens. This is being kind to the Perl parser, making it easier and less error-prone to switch between "use" (compile-time) and "require" (run-time). I've seen Perl newbies spend hours trying to figure out what is wrong because they didn't use parens when calling their user-defined functions. For example:
produces the error Bareword "Fred" not allowed while "strict subs" in use at fn.pl line 2..use strict; Fred; sub Fred { print "in function Fred\n" }
Re style guide, I quite like Abigail's My coding guidelines. If you know of any other good ones, please let me know, because I hope to (eventually) write a tutorial that will include recommendations on Perl style.
Update: See also: Re: New Discovery!!! (sub call without parentheses) - Coding Style
|
|---|