# Prepare to access configuration databases
my $db = esmith::ConfigDB->open_ro
or die "Couldn't open ConfigDB\n";
You don't need to do that inside templates - the config db records are already available as ordinary perl variables. Please read the developers guide again.
my $COMPANY-NAME = system ('config show ldap|grep defaultCompany|cut -d"=" -f2`');
All you need is:
my $COMPANY_NAME = $ldap{defaultCompany};
Note that $COMPANY-NAME is not a valid variable name - that is the variable $COMPANY minus the bareword NAME. That will generate a perl error.
my $DOMAIN-NAME = $db->get_value('DomainName');
You have the same problem with the variable name here. You can't use hyphen in a variable name.
You also can just use $DomainName here anyway, where you use $DOMAIN-NAME.
{
$OUT .= '
...
If you use single quotes - ' - then perl variables won't be interpolated into the output string - so you will have literal $DOMAIN-NAME rather than the value of the $DomainName variable.
I'd suggest you find some good basic perl tutorials on line and read them carefully multiple times.