in reply to Filling a Hash
When you do
%customer_domain_hash = split(/@@@/, $line);you are overwriting the entire hash every time whereas what really ought to happen is that only one entry should be added/changed. So, if you replace that one line with:
my ($key, $value) = split(/@@@/, $line); $customer_domain_hash{$key} = $value;
it should build up the hash on each iteration of the foreach.
Update: Unless you have duplicate keys, of course, which has been pointed out below (thanks, GotToBTru). A simple hash is not sufficient to store this. toolic's answer shows an alternative approach.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Filling a Hash
by GotToBTru (Prior) on Jul 17, 2015 at 15:52 UTC | |
|
Re^2: Filling a Hash
by Nemo Clericus (Beadle) on Jul 17, 2015 at 14:09 UTC |