Possible Duplicate:
When should I use the & to call a Perl subroutine?
I am new to Perl development and just going through sample code.
I came across &LogIt() where I have few basic questions to start with. I got info from Google like it logs error/msgs into the log file.
&LogIt("Failed to create folder.");
In the above code, what does that ‘&’ represents? Is there any difference/ impact between &LogIt() and LogIt()? Would the msg “Failed to create folder” get printed somewhere? who ll use this msg?
Kindly let me know some basics about &LogIt().
This is of archeological value. The ampersand was used to call subroutines. You will find all the gory details on that page.
It’s still works, but should not be used, except for very special situations (like reference to a subroutine or checking whether it is defined or not).
Note that
&fooand&foo()do not mean the same thing. The latter takes the arguments from the parentheses (or none, if none provided). The former cannot be called with arguments, but takes the current value of@_as arguments. Therefore, the following chunk:will produce the following output: