> I have a feeling that I am going about this in the wrong > way. Can I use hashes in a better way to sort the data based on the > keys? Better yet, can I evaluate the number of keys that match each > other?
I don't understand what that means. John Oh - I wanted to eliminate all members of the array that had more than 10 instances of the same port. I was hoping that you could do something like "count keys where port = gi1/1/49". After knowing how many gi1/1/49 there were, you could remove them if they met your high water mark. I ended out just looking for duplicates, which will achieve the basic task at hand.: ### Sort the data based on the port name @data = sort { $a-> {port} cmp $b-> {port} } @data; ### Test to see if the port names are the same (look ahead and behind) $j = 0; for($i = 0; $i <= $#data; $i++) { if ($j < $#data) { $j = $i+1; $k = $i-1; #print "$data[$i]{'vlan'}, $data[$i]{'host'}, $data[$i] {'mac'}, $data[$i]{'port'}, i = $i, j= $j, k= $k, total = $#data\n"; if ((($data[$i]{'port'} ne $data[$j]{'port'}) && ($data[$i] {'port'} ne $data[$k]{'port'})) || ($data[$i]{'port'} eq "wireless")) { open (dataDump, ">>$data_dump") or die "Can't edit $data_dump : $!"; print dataDump ("$data[$i]{'vlan'}\t$data[$i]{'host'}\t $data[$i]{'mac'}\t$data[$i]{'port'}\n"); close (dataDump); } } else { $k = $i-1; if (($data[$i]{'port'} ne $data[$k]{'port'}) || ($data[$i] {'port'} eq "wireless")) { #print "$data[$i]{'vlan'}, $data[$i]{'host'}, $data[$i] {'mac'}, $data[$i]{'port'}, i = $i, j= $j, k= $k, total = $#data\n"; open (dataDump, ">>$data_dump") or die "Can't edit $data_dump : $!"; print dataDump ("$data[$i]{'vlan'}\t$data[$i]{'host'}\t $data[$i]{'mac'}\t$data[$i]{'port'}\n"); close (dataDump); } } Ultimately, I am trying to track down MAC addresses on a network and associate them with a port. I build @data by reading in a screen scrap of every MAC address table on the network (one at a time), which is the output from a different script. I need to eliminate MACs that are trunked across other devices (they show up as a bunch of MACs on a single interface, in several other mac-address tables on other devices). By only looking for unique addresses, I can find anyone plugged into a legitimate port. However, I cannot find someone that has plugged in a Linksys switch into a port - because multiple MACs will be associated with a single port, if they have more than one active device on their device. I figure that 2 - 16 of these "bad" addresses could show up from a rogue switch. So, I figured that I'd start at 10 and tweak it from there. I thought that all this information would confuse the issue that I am trying to resolve. I hope that it is not an overload. Thank you all again for your assistance. I will keep checking back in to see if anyone has a better idea to solve what I like to call the "real world issue", versus the "everyone behaves as I want them to" problem. Even though this solves 90%+ of the problem, I want to clean up the solution a bit. Jim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/