unhappy_mage
[H]ard|DCer of the Month - October 2005
- Joined
- Jun 29, 2004
- Messages
- 11,455
I've got a chunk of code for configuring an ethernet adapter from a web-based interface, and one of the things it does is store the configuration of all the adapters on a machine before it goes changing configuration files. My code is like this:
So it initializes a pointer to a hash, then for each adapter it gets configuration data (which is returned as a hash) and stores that one level down. To display this code, I do:
This, however, is the problem: This code generates the same data for eth0 and eth1, when they should be different. Here's the real output:
However, eth1 is on the 10 subnet, and all the other values should reflect this.
Any ideas?

Code:
$configuration = { };
foreach $adapter (@adapters)
{
%temphash = getconfig("$adapter");
$configuration->{"$adapter"} = \%temphash;
}
Code:
foreach $adapter (sort(keys %{$configuration}))
{
foreach $key (sort(keys %{$configuration->{"$adapter"}}))
{
print "Adapter $adapter: $key = ", $configuration->{"$adapter"}->{"$key"}, "<br>\n";
}
}
Code:
Adapter eth0: address = 192.168.1.15
Adapter eth0: broadcast = 192.168.1.255
Adapter eth0: gateway = 192.168.1.1
Adapter eth0: netmask = 255.255.255.0
Adapter eth0: network = 192.168.1.0
Adapter eth1: address = 192.168.1.15
Adapter eth1: broadcast = 192.168.1.255
Adapter eth1: gateway = 192.168.1.1
Adapter eth1: netmask = 255.255.255.0
Adapter eth1: network = 192.168.1.0
Any ideas?