Difference between &function and function() in perl [duplicate]

It has very specific uses:

  • & tells Perl to ignore the sub’s prototype.
  • & can allow you to use the caller’s @_. (&foo; with no parens or arguments).
  • goto &foo; and defined &foo.
  • Getting a reference (e.g. \&foo).

Some people (mostly beginners) use it to distinguish user subs from builtin functions, since builtin functions cannot be preceded by &.

Leave a Comment