#!/usr/bin/perl use SNMP; # requires a hostname and a community string as its arguments $session = new SNMP::Session(DestHost => $ARGV[0], Community => $ARGV[1], Version => 1, UseSprintValue => 1); die "session creation error: $SNMP::Session::ErrorStr" unless (defined $session); # set up the data structure for the getnext command $vars = new SNMP::VarList(['ipNetToMediaNetAddress'], ['ipNetToMediaPhysAddress']); # get first row ($ip,$mac) = $session->getnext($vars); die $session->{ErrorStr} if ($session->{ErrorStr}); # and all subsequent rows while (!$session->{ErrorStr} and $$vars[0]->tag eq "ipNetToMediaNetAddress"){ print "$ip -> $mac\n"; ($ip,$mac) = $session->getnext($vars); };