3 ms·
Perl doesn't require "()" after the name of a function to call the function. In fact, parentheses aren't required for function calls at all. The code: use
by jackmaney 11y ago
Perl doesn't require "()" after the name of a function to call the function. In fact, parentheses aren't required for function calls at all.
The code:
use strict;
use warnings;
sub foo { print "In foo\n"; print "args = " . join(",",@_) . "\n" if @_; }
foo;
foo "a", "b", "c";
yields the output:
In foo
In foo
args = a,b,c
- tehwalrus 11y agoNeither does ruby. (Which is really really confusing if you spend your days in python, and occasionally have to edit something in ruby.)
- rhinoceraptor 11y agoIt's even more confusing if you have to figure out if you're calling a method or referencing a variable. The code could be assigning a new variable from a method return value, or just from an existing variable.
- deleted 11y ago[deleted]