while (($bp2, $ifIndex) = each (%bptoifIndex)) { print "$bp2\n"; # testing tool if ($bp eq "$bp2") { $mactobp{$mac} = $ifIndex; print "$mac matches with $ifIndex.\n"; }