Anonymous user
Call a function: Difference between revisions
Perl - Updated for more correctness, legibility
(added R) |
(Perl - Updated for more correctness, legibility) |
||
Line 1,090:
=={{Header|Perl}}==
The most common syntax; simply calls the function foo on the argument(s) provided.
<lang perl>foo();▼
<lang perl>foo(); # Call foo on the null list
&foo();
foo
&foo($arg1, $arg2); # Ditto; ignores prototypes</lang>
Call foo() as a bareword. Only works after the function has been declared, which
Call foo() with the current values of @_<lang perl>&foo;</lang>
Call foo() with the current values of @_, discarding the previous stack frame. Not your grandfather's (harmful) goto, although the keyword can do both.<lang perl>goto &foo;</lang>
For subroutines stored in references (anonymous subroutines).<lang perl>&$fooref('foo', 'bar');
&{$fooref}('foo', 'bar');
$fooref->('foo', 'bar');</lang>
|