I'm working on a vendor package that requires a certain format for callback hooks into a running server - the format is pretty simple:
$server_object->add_callback("function_name", "comma-separated-param_n +ames");
I've had to write a separate callback 'wrapper' for each function that I want to be able to call dynamically - but that means I have dozens of functions that look like this:
sub callback_wrapper { my ($callback_id, @params) = @_; my ($_err, $callback_data) = actual_function(@params); calback_reply($callback_id, $_err, $callback_data); return $_err; }
... and that's almost exactly the format for every callback - and I have dozens of those taking up lotsa text space and making what should be an elegant, concise file look incredibly bloated and copy/pasted. Is there anyway to dynamically generate these functions during compile-time so that I can just create an array with the callback/function names listed, then run thru the array to create the callbacks so that they can be loaded by the server during run-time?

In reply to Dynamically generating function callbacks by rick2g

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.