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.


In reply to Re: beginner - hyphen before a parameter by DStaal
in thread beginner - hyphen before a parameter by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.