Comparing substrings in two arrays
Posted on 2008-10-16
Working on a script to get CDP neighbor and interface information from Cisco switches. I'm using Net::SNMP (faster than using Net::Telnet::Cisco or an Expect script) to get OID string for interface name and pushing all names to array1. Also using SNMP to get OID string for CDP neighbor and pushing all neighbors to array2. Each of the returned strings contains an interface index number, separated from the text string by a ":", as follows:
I'd like to match up the interface name with the neighbor name by matching on the interface index. Is there a good way to compare two arrays and look for matches on substrings? I've been trying various methods like nesting foreach loops to search for matching strings, with no luck.
Thanks - Rich