I'm using Net::ARP to do an ARP lookup (using arp_lookup() from the module). For some (unknown to me) reason, when I store IP addresses as keys in a hash before handing them to arp_lookup(), they will not work unless I first assign the key to another variable. I can then use the original hash key in arp_lookup(). It seems odd to me; I've not run into this situation before. I thought at first the module might have Taint checking on, but that does not appear to be the case.
I coded up a simple example demonstrating the (again, to me) oddity. I hope it's just something I'm doing incorrectly. :)
Thank you for any insight into what is happening here.
Casey
UPDATE: I removed the $ipaddr2 assignment I mentioned. Really, any access to the $ipaddr variable between the first arp_lookup() call and second arp_lookup() call will cause the second call to work. So, the print after the first arp_lookup() fills the access role. Thank you, japhy for helping me simplify the example.
Example:#!/usr/bin/perl use warnings; use strict; use Net::ARP; my $device = q{eth0}; my %ipaddrs = ( q{192.168.1.100} => q{} ); for my $ipaddr (sort keys %ipaddrs) { my $mac = q{}; Net::ARP::arp_lookup($device, $ipaddr, $mac); print qq{$ipaddr : $mac\n}; Net::ARP::arp_lookup($device, $ipaddr, $mac); print qq{$ipaddr : $mac\n}; }
192.168.1.100 : 192.168.1.100 : 01:41:02:8F:70:80
In reply to Of Net::Arp and Hashes by cmilfo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |