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

Brad Bowman at
Sun Oct 5 21:25:24 CDT 2003

> Well... there are some (arcane, archaic and only-good-for-obfu)
> differences between calling subroutines with the ampersand and
> not, but leaving those aside... 

Arcane, but they can trip you up if you don't know.

> When you call a function foo like:
> 	print foo();		# this is the preferred way
> then this is equivalent to calling it as:
> 	print &foo();

But prototype is skipped.

> and is also equivalent (mostly, ignoring the magic stuff) to:
> 	print &foo;

[12:21 s3]$ perl -wle 'sub fn ($) { print $_[0] }; &fn()'
Use of uninitialized value in print at -e line 1.

[12:22 s3]$ perl -wle 'sub fn ($) { print $_[0] }; fn()'
Not enough arguments for main::fn at -e line 1, at end of line
Execution of -e aborted due to compilation errors.

After reading books and the like it is best to burn them or throw them away.
                                     -- Hagakure

More information about the Melbourne-pm mailing list