metaperl has asked for the wisdom of the Perl Monks concerning the following question:
Is there anyway to preserve ordering when passing it? I suppose the OO way of making a tied hash would do, but I prefer normal Perl hashes over the OO interface.use strict; use warnings; use Tie::IxHash; tie my %h, 'Tie::IxHash', (a => 1, b => 2, c => 3); warn $_ for keys %h; # prints in assigned order sub printh { my %x=@_; warn $_ for keys %x; # prints in scattered order! } printh(%h);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: having a hash maintain order when passed to a sub
by JavaFan (Canon) on May 14, 2009 at 15:33 UTC | |
|
Re: having a hash maintain order when passed to a sub
by ikegami (Patriarch) on May 14, 2009 at 16:02 UTC | |
|
Re: having a hash maintain order when passed to a sub
by Your Mother (Archbishop) on May 14, 2009 at 15:33 UTC |