in reply to What is the point of the & / ampersand sigil for function refs?
This can be handy when golfing but might cause anyone who looks at your code (including you!) some headaches...foo("\@_ has elements!"); # prints "Surprise! @_ has elements!" bar("\@_ has no elements!"); # prints "Surprise!" sub foo { # absent parens say pass my @_ &baz; } sub bar { # parens say only pass these arguments (nothing) &baz(); } sub baz { print "Surprise! ",join("\t",@_),"\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What is the point of the & sigil for function refs?
by ihb (Deacon) on Feb 11, 2005 at 14:20 UTC |