use Tie::IxHash; tie %HASH, "Tie::IxHash"; #keys in insertion order @keys = keys %HASH;