3 ms·
> functions in Perl don't have parameters Sorry, you are misinformed. That hasn't been true for a long time, see http://p3rl.org/Kavorka::Manual::Signatures ht
by bmn__ 7y ago
> functions in Perl don't have parameters
Sorry, you are misinformed. That hasn't been true for a long time, see http://p3rl.org/Kavorka::Manual::Signatures http://p3rl.org/Kavorka::Manual::Signatures
Other languages would kill for this kind of beyond-complete maximum overkill feature set.
> This page gives a good overview of the situation: https://perl101.org/subroutines.html https://perl101.org/subroutines.html
No, it doesn't. That page is not wrong, but incomplete and teaches the wrong stuff, wouldn't recommend. Instead see http://perl-tutorial.org/ http://perl-tutorial.org/ for recommended tutorials.
- rubinelli 7y agoFrom the Perl 5.30 documentation: > WARNING: Subroutine signatures are experimental. The feature may be modified or removed in future versions of Perl. https://metacpan.org/pod/perlsub https://metacpan.org/pod/perlsub
- mmcclimon 7y agoIt's true that they're experimental, but it's extremely unlikely they'll be removed. The only reason they weren't stable in the most recent version of perl is because of some interactions with subroutine attributes (specifically, :lvalue) which needed some tweaking. We use them everywhere at Fastmail and they're great. Which is to say: a lot of the reason they're still experimental is because Perl's commitment to backward compatibility. Other languages might have said "oh well," but Perl 5 said "oh, an unintended consequence that might break real uses in the wild; we should wait another year."
- iosonofuturista 7y agoSo, the first tutorial on the list that you recommend has this page for functions[0]. It's more or less the same as GP's link. YOU are the one misinforming, it would seem. Granted, I don't work with perl (5, never tried 6) for about 15 years, but most criticism of it seems to align with my experiences back then. [0] http://mvp.kablamo.org/basics/functions/ http://mvp.kablamo.org/basics/functions/ Edit: The second [1] also recomends the @_ method, and the third [2] the shift method. Did you even read your own links? [1] https://perlmaven.com/subroutines-and-functions-in-perl https://perlmaven.com/subroutines-and-functions-in-perl [2] https://learnxinyminutes.com/docs/perl/ https://learnxinyminutes.com/docs/perl/ (search for subroutines)
- marcosdumay 7y agoIn my experience, I never got positional parameters to reliably work on Perl5. They were always buggy and would break with completely unrelated changes. On Perl6 those are officially supported, so I imagine they work.