|Pathologically Eclectic Rubbish Lister|
Re^3: Any difference between use and require regarding honoring prototype defined for sub?by Athanasius (Monsignor)
|on Nov 20, 2012 at 04:50 UTC||Need Help??|
Hello stewart_lee, and welcome to the Monastery!
I use 'use', then I should call the sub with ($$@@) instead of ($$\@\@)
I think you may be confused about how prototypes work in Perl. Specifically, ($$\@\@) means the subroutine expects:
The backslash in the prototype — \@ — means the array will be converted into an array reference inside the sub. So, in your example,
the variables $values and $movingAve are assigned references to the arrays @values and @mv, respectively, by virtue of the subroutine’s prototype.
Perl prototypes are confusing, and should probably be avoided unless you have a good reason to use them. Make sure to read Far More than Everything You've Ever Wanted to Know about Prototypes in Perl -- by Tom Christiansen.
By the way, you would probably have received help sooner had you posted a trimmed-down (but still working) version of the code showing only the relevant parts. See How do I post a question effectively?
And do not comment out use strict; — it’s there to make your life easier!
Hope that helps,
Athanasius <°(((>< contra mundum