You could use either an array or (probably better) a hash something like this:
my %cmdtable=( ### general OID for system up time sysUpTime => '1.3.6.1.2.1.1.3.0', ### These are Cisco OID's which i use for the AS5400 bank ModemsAvailable = '1.3.6.1.4.1.9.9.47.1.1.7.0', ModemsUnavailable = 1.3.6.1.4.1.9.9.47.1.1.8.0')
and then indeed you can do a
my @results; for (keys %cmdtable) { ...
If you need them ordered you can EITHER have the order in a separate array or have 2 arrays one for command and one for the OID.

Assuming you need to do this sort of thing for many devices and you wish to do it in a reasonable timeframe you may want to look at POE as that should nicely cope with multiple parallel SNMP requests an responses. I seem to recall from days querying SNMP devices that responses are often in the seconds (or worse if you have to retry), which means that if you need to do 100 queries on 100 differnt devices in a strict sequence you get a script that runs for 3 hours instead of under two minutes! POE should let you parallelise nicely - indeed the POE cookbook may actually have sample code for this thing.

Dingus


Enter any 47-digit prime number to continue.

In reply to Re: Making a scalable Net::SNMP script? by dingus
in thread Making a scalable Net::SNMP script? by enigmae

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.