Think about Loose Coupling | |
PerlMonks |
Regex matching part of one hash key to anotherby KevinNC (Initiate) |
on Jan 06, 2011 at 23:02 UTC ( [id://880962]=perlquestion: print w/replies, xml ) | Need Help?? |
KevinNC has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I'm new to perl and to this site (it has been an HUGE help) and I'm having a problem I am hoping someone can assist me with solving. Basically I am trying to prevent a lengthy manual process of searching the OUI of a routers ARP cache to find the Company. We have tools but no access so I'm stuck with finding a faster way. The problem I'm having is I can match the first iteration of the ARP cache hash but afterwards it stops matching altogether and just iterates the rest with blank results. Below is the code I have so far, please be kind as I am still learning, a small arp cache file and the resulting output :) Thanks in advance for any and all assistance.
this is the input file tech.txt (IP and MAC addresses changed to protect my job) :D Internet 10.10.10.1 - 000b.462d.2846 ARPA FastEthernet0 Internet 10.10.10.2 1 0013.2004.acde ARPA FastEthernet0 Internet 10.10.10.3 7 0800.4ec8.94ac ARPA FastEthernet0 This is the reulting output 10.10.10.2 mapped to 00132004acde for company Intel Corporate! 10.10.10.3 mapped to 08004ec894ac for company ! 10.10.10.1 mapped to 000b462d2846 for company ! As you can see I can only get the first iteration to match and can only seem to get it using subtr, afterwards it just stops. I can iterate through the hash just fine and print it out, seems from the examples I've found it should work. I have tried various other ways but thats the furthest I have been able to get so far as most of the time I dont get any matches on the Company name. Also, I wasn't sure how to get the oui.txt up in the post for testing as it's a pretty big file. Thanks again. :)
Back to
Seekers of Perl Wisdom
|
|