in reply to sorted Hash
I don't know how you populate your hash, but you wouldn't need to sort at all if you used an array instead:
my @SRV = ( 'zumen530n.pdg.duranto.com', 'zumen531n.pdg.duranto.com', 'zumen532n.pdg.duranto.com', # etc ); print "$_ $SRV[ $_ ]\n" for 0 .. $#SRV;
Of course, this prints 0-20 instead of 1-21, but that's easy to fix if it's important.
Update: In fact, whenever I see a hash like:
my %h = ( 1 => 'foo', 2 => 'bar', 3 => 'baz', 4 => 'quux', );
I always consider whether it wouldn't be better to use a simple array.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sorted Hash
by marioroy (Prior) on Aug 24, 2015 at 06:29 UTC |