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;