in reply to Re: Parsing a hash table for only variables that are uppercase.
in thread Parsing a hash table for only variables that are uppercase.

While it goes beyond the scope of the problem, a hash can be made to be ordered by using the CPAN module Tie::IxHash.

Link to Tie::IxHash documentation
Link to Tie::IxHash tarball

Usage:

#!/usr/bin/perl -w

use strict;
use Tie::IxHash;

tie my %ordered_hash, Tie::IxHash;

%ordered_hash = (a => 1, b => 2, c => 3);

foreach my $key ( keys %ordered_hash ) {
    print "$key\t$ordered_hash{$key}\n";
}

# prints:
# a     1
# b     2
# c     3

exit 0;

Cheers,
Richard

  • Comment on Re: Re: Parsing a hash table for only variables that are uppercase.