in reply to What is the point of the & / ampersand sigil for function refs?
The & prefix also disables prototype checking, but you shouldn't be using prototypes in the first place, so I consider that a very minor point, but if I didn't mention it, someone else would surely raise that flag. {grin}
In our Learning Perl book, we suggest that you always use the ampersand when you're first learning Perl, because otherwise you'll be a bit befuddled when the following code doesn't work:
Yes, you're not calling your log subroutine... you're calling the built-in "logarithm" function. Oops.sub log { print STDERR "logging: ", @_, "\n"; } ... log("starting"); ... log("finishing"); ...
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: What is the point of the & sigil for function refs?
by Random_Walk (Prior) on Feb 04, 2005 at 12:28 UTC |