Re: [Setup-tool-hackers] A comment on Perl style.



On 17 Aug 2001 19:32:26 -0400, Arturo Espinosa Aldama wrote:
> 
> Please, do use the ampersand and the parenthesys when calling functions in
> your code, even if the function doesn't receive parammeters (&function
> ()). Also, use a space between the parenthesys and the function name. This
> makes it easier to do massive sed replacements.

There's more important reasons why everyone should always call functions
with parenthesys: If you use just &func; then caller's @_ get's passed
to func which isn't usually what you meant. That's why you should always
use &func (); form. Here's a little example which prints out "Hello
World!":

sub func1
{
	foreach (@_) { print $_ }
}

sub func 2
{
	&func1;
}

&func2 ("Hello World!");

Tambet


_______________________________________________
setup-tool-hackers maillist  -  setup-tool-hackers@ximian.com
http://lists.ximian.com/mailman/listinfo/setup-tool-hackers



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]