What dose the ( $$ )
do in this code. I have programmed Perl for a long time but never came across this syntax until recently when I opened a very old Perl .plx file
These rows prevent me from upgrading to a more modern Perl version.
sub help( $$ ){
}
The reason it affects me is because I get an error message stating that the help function was called before it was declared. Any idea of how I can solve this without removing the ( $$ ) block??
The are called prototypes. This particular one says that the sub routine expects to be called with exactly 2 scalar variables. Although prototypes are sometimes useful, mostly they are not.
If you can drop them depends on the rest of the code...
That's a function prototype, which is used to specify the number and types of arguments that the subroutine takes. See the documentation.
Since it's in the current documentation, I don't see why it's preventing you from upgrading.
Is the error you're getting help called too early to check prototype
? Here's the explanation from the perldiag documentation:
(W prototype) You've called a function that has a prototype before the parser saw a definition or declaration for it, and Perl could not check that the call conforms to the prototype. You need to either add an early prototype declaration for the subroutine in question, or move the subroutine definition ahead of the call to get proper prototype checking. Alternatively, if you are certain that you're calling the function correctly, you may put an ampersand before the name to avoid the warning. See perlsub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With