as a matter of style, i think always having them is nice for maintenance/readability.
-Tom Kinzer -----Original Message----- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 8:08 AM To: [EMAIL PROTECTED] Subject: Re: Parentheses Paul Kraus wrote: > > Ok another question on perl then. When do you have to use () on a > function or sub call? Or in the new construct of an object. > I use then on everything since I don't better. Figure its safer to leave > them on then take them off. Very simply, if you've previously declared a subroutine either explicitly or by importing from a module then it becomes a list operator. It will be passed everything listed in the call and you don't need parentheses. If you're calling an undeclared subroutine, or the call is ambiguous without them then you need parentheses. Built-in functions and prototyped subroutines behave exactly how you say they should. But forget about prototyping subroutines: it almost never the way to go. Take a look at the program below. I hope this helps. Rob sub subA; # Predeclare just subA subA 1, 2, 3, 4; subA (1), 2, 3, 4; # subB 1, 2, 3, 4; # Syntax error subB (1, 2, 3, 4); subB (1), 2, 3, 4; sub subA { print "SubA: ", scalar @_, " parameters\n" }; sub subB { print "SubB: ", scalar @_, " parameters\n" }; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>