in reply to Sorting hash references
Of course, this begs the question - why use %hash at all - hopefully, you have a reason for that - need quick/random reference to the keys for an unstated reason.my %hash; my @ordered_keys; while ( my $line = <DATA> ) { chomp $line; next unless $line; my ( $key, $value ) = split /\s*=\s*/, $line; $hash{$key} = $value; push @ordered_keys, $key; } # No need to sort - @ordered_keys is already in the right sequence... print "$_ = $hash{$_}\n" for @ordered_keys;
By guaranteeing freedom of expression, the First Amendment also guarntees offense.