in reply to Re^5: perl sort issue while going through article at perl.com
in thread perl sort issue while going through article at perl.com
A hash is like an array but the index can be text instead of a number. so when you write
my %hash = ( key1 => 'value1', key2 => 'value2', key3 => 'value3', key3 => 'value3', key3 => 'value3', key1 => 'value3',
the second time you do key1 => ... it will overwrite any earlier value of key1.
There will only ever be one value associated with each key, so when you
foreach (sort keys %hash) { $hist{$_}++; }
each key will be unique, so the count will be one for each of them
You need to study hashes more. Perhaps perldsc will be of help
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: perl sort issue while going through article at perl.com
by convenientstore (Pilgrim) on Oct 24, 2007 at 00:46 UTC |