I would build a hash of hashes. hash of hashes of hashes if you're gathering more than one segment of the snmp data. of course, CPAN is always a first choice but this would work in a pinch.
#!/usr/bin/perl use strict; my %users; while (<DATA>) { $users{$1}{$2}=$3 if /1\.1\.5\.1\.\d\.(\d)\ (\w+)\ (\w+)/; } use Data::Dumper; print Dumper(%users); __DATA__ 13 1.3.6.1.4.1.546.1.1.5.1.1.1 INTEGER 1 13 1.3.6.1.4.1.546.1.1.5.1.1.2 INTEGER 2 13 1.3.6.1.4.1.546.1.1.5.1.1.3 INTEGER 3 13 1.3.6.1.4.1.546.1.1.5.1.1.4 INTEGER 4 13 1.3.6.1.4.1.546.1.1.5.1.2.1 OctetString user 13 1.3.6.1.4.1.546.1.1.5.1.2.2 OctetString user 13 1.3.6.1.4.1.546.1.1.5.1.2.3 OctetString user 13 1.3.6.1.4.1.546.1.1.5.1.2.4 OctetString user 13 1.3.6.1.4.1.546.1.1.5.1.3.1 OctetString pts/2 13 1.3.6.1.4.1.546.1.1.5.1.3.2 OctetString pts/3 13 1.3.6.1.4.1.546.1.1.5.1.3.3 OctetString pts/4 13 1.3.6.1.4.1.546.1.1.5.1.3.4 OctetString pts/5 13 1.3.6.1.4.1.546.1.1.5.1.4.1 INTEGER 10096 13 1.3.6.1.4.1.546.1.1.5.1.4.2 INTEGER 11928 13 1.3.6.1.4.1.546.1.1.5.1.4.3 INTEGER 4 13 1.3.6.1.4.1.546.1.1.5.1.4.4 INTEGER 21612 13 1.3.6.1.4.1.546.1.1.5.1.5.1 TimeTicks 11d 07:39:59 13 1.3.6.1.4.1.546.1.1.5.1.5.2 TimeTicks 9d 05:47:57 13 1.3.6.1.4.1.546.1.1.5.1.5.3 TimeTicks 14d 03:29:03 13 1.3.6.1.4.1.546.1.1.5.1.5.4 TimeTicks 0d 00:29:52 13 1.3.6.1.4.1.546.1.1.5.1.6.1 OctetString machine.domain.com 13 1.3.6.1.4.1.546.1.1.5.1.6.2 OctetString machine.domain.com 13 1.3.6.1.4.1.546.1.1.5.1.6.3 OctetString machine.domain.com 13 1.3.6.1.4.1.546.1.1.5.1.6.4 OctetString machine.domain.com

In reply to Re: Parsing SNMP output by bageler
in thread Parsing SNMP output by Anonymous Monk

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.