#### #### use Data::Dumper; # This is actually in @body in the larger code open(TMPL, "((?s:.*?))))[0]; $Data::Dumper::Sortkeys = \%template; print Dumper(\%template); #### use Data::Dumper; open(TMPL, ") { next if /^#/; if (m!!) { my %hash = ($tmpl =~ /^s+(\w+)\s+=\s+(.*)$/mg); if (%hash) { $Data::Dumper::Sortkeys = \%hash; print Dumper(\%hash); } else { print "Bad template: $tmpl\n"; } } elsif (defined $tmpl) { s/^\s+/ /; s/[ \t]$//; s/=\s*\z/= /; $tmpl .= $_; } } close TMPL; #### $VAR1 = { 'bar' => '0', 'blort' => 'home_url = http://www.foo.com/some/really/long/url', 'foo' => 'Yes' }; #### my $conf = new Config::General( -ConfigFile => "pler.template", -ExtendedAccess => 1, -InterPolateVars => 1, -AutoTrue => 1, -StrictObjects => 0, ); my %config = $conf->getall; my $template = $conf->obj('template'); my %params = %{$config{'template'}}; for (keys %{$config{template}}) { if (/^http/) { $config{template}{home_url} = $_; delete $config{template}{$_}; last; } } $Data::Dumper::Sortkeys = \%config; print Dumper(\%config);