# # # # # # # # # # # # SQL MAC Query # # # # # # # # # # # # our $smq = $dbh->prepare("select distinct mac,comment from arp.filter where operation = 'filter' order by mac") or die "Couldn't prepare statement: " . $dbh->errstr; # # # # # # # # # # # # # # # # # SQL Distinct MAC Table # # # # # # # # # # # # # # # # # $smq->execute() or die "Couldn't execute statement: " . $smq->errstr; print "# SQL Distinct MAC HASH #\n"; # +----------------+-------------------------------------+ # | mac | comment | # +----------------+-------------------------------------+ # | 1226.b0ab.317e | roving filtered mac | # | 1226.b0ab.317e | roving filtered mac [force filter | # | 1226.b0ab.317e | [thor2] Excessive Campus Bandwidth | # +----------------+-------------------------------------+ # 3 rows in set (0.04 sec) our $mac_t = "1226.b0ab.317e"; my $ref = $dbh->selectall_hashref("select distinct mac,comment from arp.filter where operation = 'filter' order by mac", 'mac'); foreach my $id (keys %$ref) { if ($mac_t eq $ref->{$id}{mac}) { print "Found a row: mac = $ref->{$id}{mac}, comment = $ref->{$id}{comment}\n"; } }