while (<DATA>)
{
# match any dollar followed by a number
# of non whitespaces (unicode safe)
# and replace it by then corresponding
# environment variable
if ( s/\$(\P{IsSpace}+)/$ENV{$1}/ )
{
$undefinedVars++
unless $ENV{$1};
}
print;
}
if ( $undefinedVars > 0)
{
print "\n\nERROR: There were $undefinedVars undefined variables!\n
+";
}
__DATA__
bigcompany.product.part.path=$PATH
bigcompany.product.part.widgit=$WIDGIT
bigcompany.product.part.battery=$BATTERY
bigcompany.product.part.frobnicator=$FROBNICATOR