4 ms·
Yes, built-in since Perl 5.20, released mid 2014. use experimental qw(signatures); sub plus_one($x = 100) { return $x + 1; } # Says 6. say pl
by jlokier 7y ago
Yes, built-in since Perl 5.20, released mid 2014.
use experimental qw(signatures);
sub plus_one($x = 100) {
return $x + 1;
}
# Says 6.
say plus_one(5);
# Says 101.
say plus_one();
(The subroutine signatures feature is still marked experimental, which is a shame.
I use it in virtually all my code, unless I want pre-5.20 compatibility.)
- zbentley 7y agoNeat, thanks! I can't use it unfortunately (the little Perl I still write targets 5.8 on ancient CentOS, but that's not the language's fault). Good to see it still evolving!