>>>>> "Ricardo" == Ricardo SIGNES <[EMAIL PROTECTED]> writes:
Ricardo> Here are some of the reasons you'd need &:
Ricardo> The subroutine has a prototype, and you want to circumvent it.
Ricardo> sub foo($$) { ... }
Ricardo> &foo(1);
Ricardo> You want to pass @_ as the arguments to the called function.
Ricardo> sub foo { &bar; } # passes the arguments to foo to bar
Ricardo> You're calling a subroutine reference.
Ricardo> $foo = sub { ... };
Ricardo> &$foo;
You've named the subroutine the same as a Perl built-in word,
either deliberately or accidentally:
&chomp;
sub chomp { ... };
This is why we still tell beginners to use & in the llama class. I
had a heckuva time with a student in one class who had decided to call
their logging subroutine "log", and then try to call it without an
ampersand. Oops.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>