I'll just go and assume that your arguments are known at compile time because ... well ... your question doesn't make much sense otherwise. If this checking is really that important to you, you could always try source filtering. With Filter::Simple you could try to find every calls to that function (and I'm not talking about special cases like calling from a sub reference, because there's no prototype checking there either) and check the parameters.

If you call it only like MySub( {key => value, otherKey => value, ... } ) you could do with a regex. And if you call it like MySub(CanYieldAHashRefAtCompileTime); You could use your filter to get the parameters as a string, eval it (which would give you a hashref), make your verification, and even replace the string by its "value" by using Data::Dumper. That probably is a bad idea if your data contains bless references (instances) or tied variables.

So you could do it, and that wouldn't be that difficult provided you read the documentations carefully, but you should still ask yourself if it really is worth the trouble and added complexity to your program.


In reply to Re: How to make script die with "Not enough args" on compilation step if args are passed as a hash ref? See inside by Eily
in thread How to make script die with "Not enough args" on compilation step if args are passed as a hash ref? See inside by Doctrin

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.