And here's my version:
use autodie;
use strict;
my $rawout = "protojson/plantproperties.json";
my $rawin = "protojson/plantproperties.protojson";
open (my $RAWIN, "<", $rawin);
open (my $RAWOUT, ">", $rawout);
print $RAWOUT "[\n";
for my $line (<$RAWIN>) {
chomp (my $myline = $line);
my @entries = split /\t/, $myline;
my $jstr = jsontemplate();
my $i = 0;
$jstr =~ s/%/$entries[$i++]/eg;
print $RAWOUT $jstr;
}
print $RAWOUT "]\n";
sub jsontemplate {return <<"ENDJSON"}
{
"name" : "%",
"annual" : "%",
"isTree" : "%",
"maxLAI" : %,
"stage 6" : %,
"stage 7" : %,
"stage 9" : %,
"stage 10" : %,
"base temp" : %,
"water tolerence" : %,
"max height" : %,
"max root depth" : %,
"starting nitrogen" : %,
"final nitrogen" : %,
"day neutral" : "%",
"flowering min temp" : %,
"flowering optimal temp" : %,
"floral induction units" : %,
"long day" : "%",
"minimum induction" : %,
"critical night length" : %,
"min growth temp" : %,
"optimal growth temp" : %,
"base" : {
"stem" : %,
"root" : %,
"storage" : %,
"fruit" : %
},
"flowering" : {
"stem" : %,
"root" : %,
"storage" : %,
"fruit" : %
},
"final" : {
"stem" : %,
"root" : %,
"storage" : %,
"fruit" : %
},
"germination min temp" : %,
"germination optimal temp" : %,
"germination thermal units" : %,
"average fruit weight" : %,
"seed ratio" : %,
"dormancy" : %,
"default dormancy" : "%",
"dormant height decrease" : %,
"dormant root decrease" : %,
"dormant biomass" : {
"stem" : %,
"root" : %,
"storage" : %,
"fruit" : %
}
},
ENDJSON