in reply to RE: Re: Multiple identical keys in a hash.
in thread Multiple identical keys in a hash.
Then you will have something like this:foreach $f (@files) { open FILE, $f or die "Error: $!"; while(<FILE>) { chomp; my ($k,$v)=split("=",$_,2); # Assume dn= comes before other lines $level1=$k, next if $k eq "dn"; unless ($level1) { die "Need to get dn= line first\n"; } push @{$hash{$level1}{$k}}, $v; } close FILE; }
And then do comparisons or anything else you need. See chapter 4 of The Perl Cookbook for examples of how to do fancy array operations, including comparisons.$hash{machinename}{config}=["2000"] $hash{machinename}{speed}=["19200"] $hash{machinename}{setting}=["value1", "value2", "value3"] $hash{machinename2}{config}=["2020"] etc.
|
|---|