I'm back to adding features in a script that I've been hacking on for quite a while now that deals with net::snmp. The module has a few method that use the standard format of $object->method(-argument => $value);

Since a method can have quite a number of -argment options passed to it at once, is there a method of passing them to the object through an array or an array reference? or perhaps I should be asking about passing them through a hash/hash reference. It seems as though I've read this as being a possibility with other modules, but I don't believe its present in net::snmp. Is this something that is module-specific or a standard that I can work on?

I guess my hypothesis is...

my %arguments = ( argument1 => "value1", argument2 => "value2" ); $object->method(%arguments);

Would equate to...

$object->method( -argument1 => "value1", -argument2 => "value2" );

Is this just wishful thinking?

thanks very much on this one -c


In reply to pass Array/Hash reference to a module method? by c

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.