in reply to Taking Input from PID

I think SNMP Trap Translator (which is written in Perl) will either do what you need, or provide invaluable pointers on how to do what you need...