in reply to Re^3: SNMP Trap Decoding issue
in thread SNMP Trap Decoding issue

I have wrapped the HEX code sorry for that. What do you mean with OP

I have tried your code as follows but it does not produce any output:
#!/usr/bin/perl use Encoding::BER::SNMP; my $temp="3014060e2b06010401090929010203010200040232303013060e2b060104 +01090929010203010300020105301d060e2b06010401090929010203010400040b537 +9736c6f67205472617030818c060e2b06010401090929010203010500047a31303630 +32333a2044656e792069636d7020737263206f7574736964653a3231362e3139362e3 +6342e3132342064737420696e736964653a3230382e3130392e39302e323120287479 +706520382c20636f6465203029206279206163636573732d67726f757020226f75747 +36964655f6163636573735f696e223016060e2b060104010909290102030106004304 +73c36bf8"; $data .= chr hex $1 while $temp=s/(..)//; my $enc = Encoding::BER::SNMP->new(); while ($data) { my $result = $enc->decode($data); my $oid = $result->{'value'}->[0]->{'value'}; my $value = $result->{'value'}->[1]->{'value'}; print "returned pair: $oid -> $value\n"; my $back = $enc->encode($result); $data =~ s/\Q$back\E// or last; }
I am starting to feel that I am doing really stupid but I just can't see what :-)

Replies are listed 'Best First'.
Re^5: SNMP Trap Decoding issue
by ikkeniet (Acolyte) on May 04, 2007 at 16:07 UTC
    I solved it (maybe unconvential perl coding but it worked) It finally works thanks to your valuable help shmem!
Re^5: SNMP Trap Decoding issue
by shmem (Chancellor) on May 04, 2007 at 16:16 UTC
    You missed a ~
    - $data .= chr hex $1 while $temp=s/(..)//; + $data .= chr hex $1 while $temp=~s/(..)//;

    OP = original post(er). BTW, welcome to the monastery! :-)

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}