cmilfo has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Of Net::Arp and Hashes
by japhy (Canon) on Jan 13, 2006 at 19:14 UTC | |
by cmilfo (Hermit) on Jan 13, 2006 at 19:18 UTC | |
by japhy (Canon) on Jan 13, 2006 at 20:12 UTC | |
by idsfa (Vicar) on Jan 14, 2006 at 03:46 UTC | |
|
Re: Of Net::Arp and Hashes
by idsfa (Vicar) on Jan 13, 2006 at 18:51 UTC | |
by cmilfo (Hermit) on Jan 13, 2006 at 19:05 UTC | |
|
Re: Of Net::Arp and Hashes
by japhy (Canon) on Jan 13, 2006 at 18:19 UTC | |
by cmilfo (Hermit) on Jan 13, 2006 at 18:30 UTC | |
by japhy (Canon) on Jan 13, 2006 at 18:39 UTC | |
|
Re: Of Net::Arp and Hashes
by glasswalk3r (Friar) on Jan 13, 2006 at 18:22 UTC | |
by cmilfo (Hermit) on Jan 13, 2006 at 18:35 UTC |