title: Difference between &function and function() in perl
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1347396/when-should-i-use-the-to-call-a-perl-subroutine">When should I use the &amp; to call a Perl subroutine?</a>  </p>
  </blockquote>
  
  
  
  <p>In perl scripts, why is that method of invoking the function is written differently some times. I see &amp;function and sometimes function(). Are they both the same and this is just a style that one would want to flaunt? If they are the same, why are they both available, would not one just suffice? I am guessing there is some semantic difference between the both the methods which distinguishes them from each other ... but at what kind of circumstances?</p>
  
  <p>--- Since I cannot answer my own question for timeout reasons -- I am updating the answer in the section of question  itself. When I get a chance to update the answer block, I will put it there.</p>
  
  <p>I found the relevant text in 'Learning Perl' book..thanks for the tip though. Chapter 4: Subroutines -- Omitting the Ampersand.</p>
  
  <p>I was more interested in ampersand <em>&amp;</em> usage for perl functions. If a subroutine is already defined before being invoked, then subroutine can be invoked without using <strong>&amp;</strong> while calling the function similar to invoking the builtin functions. &amp; is also used to distinguish between the builtin functions and the user defined functions if the function to be invoked uses the same name that of one of the builtin function, provided it is defined before being invoked.</p>
  
  <p>Usage of (), is merely to justify the passing of the arguments to the subroutines, while if not used, the default list of current arguments are passed in the form @_. If the arguments are specified in () for a subroutine, it is assumed to be a subroutine and is invoked even if not previously defined while parsing.</p>