PerlGP is a strongly typed system. In fact, all evolved code must be syntactically correct to be awarded fitness. When random individuals or subtrees are generated, PerlGP follows a grammar (defined by the user). The format of this grammar is analogous to the tree-as-hash encoding described above, and is explained in the code below:
$F{ROOT} = [ '{STATEMENT}' ];
$T{ROOT} = [ '# nothing' ];
$F{STATEMENT} = [ 'print "{STRING}!\n";',
'$s = "{WORD}";',
'{STATEMENT}
{STATEMENT}' ];
$T{STATEMENT} = [ '# just a comment',
'chomp($s);',];
$F{STRING} = [ '{STRING}, {STRING}',
'{WORD}' ];
$T{STRING} =
$T{WORD} = [ 'donuts', 'mmm', '$s' ];