It's not hard to modify it so that the location of the use statement doesn't matter:

package Signatures; my @packages; sub import { my $package = caller; push @packages, $package; } INIT { for my $package (@packages) { no warnings; no strict; for (keys %{ $package . '::' }) { next unless exists &{ $package . "::$_" }; my $sub = \&{ $package . "::$_" }; next unless my $proto = prototype $sub; eval qq { package $package; sub $_ { local ($proto) = \@_; \$sub->() } } } } } 1;
It still seems like the function using the prototype has to be defined AFTER any calls to it though. And modules using the Signatures have to be used after all calls to the functions in them. Otherwise I get "Malformed prototype for foo: $a,$b at C:\temp\Proto\test.pl line 6." Not sure if there is any way around that. And I don't see any way to lexicalize the parameters and make strict happy.

Jenda
XML sucks. Badly. SOAP on the other hand is the most powerfull vacuum pump ever invented.


In reply to Re^2: Your named arguments by Jenda
in thread Your named arguments by Juerd

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.