> -----Original Message-----
> From: Octavian Rasnita [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 04, 2002 2:06 PM
> To: [EMAIL PROTECTED]
> Subject: subroutine or &subroutine
> 
> 
> Hi all,
> 
> I've seen some subroutines are ran without the & sign in front of the
> subroutine name, like:
> 
> subroutine_name;
> instead of
> &subroutine_name;
> 
> Is it the same thing or there is a difference?

Janek gave you the difference, and it's fully documented in perldoc perlsub.

Note that the first is not allowed under "use strict" unless the sub has
been declared or defined above the usage, or imported.

Here are my recommendations for new code (others may want to debate these):

1. Always "use strict;"

2. Don't use prototypes.

3. Don't use the &foo or &foo(args) calling styles.

4. To call a sub with no arguments, use an empty set of
   parens: foo() (Exception: method calls can leave
   off the parens, e.g: $sth->execute; since there is
   no ambiguity with a method call).

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to