Useless use of a (constant|hash element) in void context?

Brad Bowman at
Sun Oct 5 21:19:39 CDT 2003

> > If you prefix something with an ampersand you're saying that it's a
> > subroutine:
> > 	&some_sub();
> Ok, so when I call a function foo like:
> 	print foo;
> I'm implying:
> 	print &foo();
> ... assuming there are no variables called foo in the current
> context/scope?

The & call prefix may do other stuff too.  It's ol' skool so dodges
prototypes and if used like &blah with no parens it gets the
parents @_.  Rarely what you want, so careful with &.
(The \&sub for a reference to a named sub is ok though)

> I guess I've always been curious - what's the difference between
> prefixing something with an ampersand or a backslash? 

Are you a C programmer by chance?

... There is dignity in paucity of words. ... -- Hagakure

More information about the Melbourne-pm mailing list