$ diff -u Tiny.pm.orig Tiny.pm --- Tiny.pm.orig 2015-07-06 12:51:54.000000000 -0400 +++ Tiny.pm 2015-07-06 13:02:22.000000000 -0400 @@ -3,6 +3,7 @@ # If you thought Config::Simple was small... use strict; +use Hash::Ordered; # Warning: There is another version line, in t/02.main.t. @@ -39,7 +40,8 @@ # Create an object from a string sub read_string { my $class = ref $_[0] ? ref shift : shift; - my $self = bless {}, $class; + tie my %obj, 'Hash::Ordered'; + my $self = bless \%obj, $class; return undef unless defined $_[0]; # Parse the file @@ -59,7 +61,10 @@ # Create the sub-hash if it doesn't exist. # Without this sections without keys will not # appear at all in the completed struct. - $self->{$ns = $1} ||= {}; + $self->{$ns = $1} ||= do{ + tie my %obj, 'Hash::Ordered'; + \%obj; + }; next; } #### $ perl test.pl [insert] SQL1 = insert into table SQL2 = insert into table SQL3 = insert into table SQL4 = insert into table [Truncate] SQL1 = truncate table SQL2 = truncate table [update] SQL1 = update into SQL2 = update into