in reply to beginner - hyphen before a parameter
Nothing... Except it identifies the 'name' of the parameter.
Perl does not have named parameters. It passes the entire set of parameters to the subroutine as a list. (Elements of which can be references to other structures, of course.) So the code shown only looks like you are passing a hash. You are actually passing a list.
Therefore, the subroutine has to turn that list into something useful. In the above, they likely are trying to be nice, and letting you present the arguments in any order, like a hash. But to do so, they need to know which order they are actually in. A simple way is to create a set of reserved words, look for them in the parameter list, and say that the next item in the list is the argument for that reserved word. And, of course, you want a reserved word that will never be used, is recognizable as such, and if possible allows expansion using the same pattern, in case you need more arguments later.
Putting a hyphen in front of a word satisfies all of the above, fairly simply, and in a way that anyone familiar with a Unix-style commandline will understand.
So, it's just a convention, but a useful one.
|
---|