in reply to Retaining hash order with Config::General?
I cooked together a simple patch based on bart's suggestion, submitted to the module author also. My module version is 2.40 (latest
WARNING: Barely tested. Use at your own risk. Works for Me(tm).
1107c1107 < $config_string = $this->_store(0, %{$this->{config}}); --- > $config_string = $this->_store(0, \%{$this->{config}}); 1114c1114 < $config_string = $this->_store(0,%{$config}); --- > $config_string = $this->_store(0,\%{$config}); 1140c1140 < return $this->_store(0, %{$this->{config}}); --- > return $this->_store(0, \%{$this->{config}}); 1147c1147 < return $this->_store(0, %{$config}); --- > return $this->_store(0, \%{$config}); 1158c1158 < my($this, $level, %config) = @_; --- > my($this, $level, $config) = @_; 1169,1171c1169,1171 < foreach my $entry (sort keys %config) { < if (ref($config{$entry}) eq 'ARRAY') { < foreach my $line (sort @{$config{$entry}}) { --- > foreach my $entry (sort keys %{ $config }) { > if (ref($$config{$entry}) eq 'ARRAY') { > foreach my $line (sort @{$$config{$entry}}) { 1173c1173 < $config_string .= $this->_write_hash($level, $entry, $li +ne); --- > $config_string .= $this->_write_hash($level, $$entry, $l +ine); 1176c1176 < $config_string .= $this->_write_scalar($level, $entry, $ +line); --- > $config_string .= $this->_write_scalar($level, $$entry, +$line); 1180,1181c1180,1181 < elsif (ref($config{$entry}) eq 'HASH') { < $config_string .= $this->_write_hash($level, $entry, $config +{$entry}); --- > elsif (ref($$config{$entry}) eq 'HASH') { > $config_string .= $this->_write_hash($level, $$entry, $$conf +ig{$entry}); 1184c1184 < $config_string .= $this->_write_scalar($level, $entry, $conf +ig{$entry}); --- > $config_string .= $this->_write_scalar($level, $$entry, $$co +nfig{$entry}); 1189,1191c1189,1191 < foreach my $entry (keys %config) { < if (ref($config{$entry}) eq 'ARRAY') { < foreach my $line (@{$config{$entry}}) { --- > foreach my $entry (keys %{ $config }) { > if (ref($$config{$entry}) eq 'ARRAY') { > foreach my $line (@{$$config{$entry}}) { 1200,1201c1200,1201 < elsif (ref($config{$entry}) eq 'HASH') { < $config_string .= $this->_write_hash($level, $entry, $config +{$entry}); --- > elsif (ref($$config{$entry}) eq 'HASH') { > $config_string .= $this->_write_hash($level, $entry, $$confi +g{$entry}); 1204c1204 < $config_string .= $this->_write_scalar($level, $entry, $conf +ig{$entry}); --- > $config_string .= $this->_write_scalar($level, $entry, $$con +fig{$entry}); 1269c1269 < $config_string .= $this->_store($level + 1, %{$line}); --- > $config_string .= $this->_store($level + 1, \%{$line});
|
|---|