the daily "what-the-f…."

alles ziemlich selbsterklärend 😉

sub replaceVariables {
my ($line, $dir) = @_;
my @lsplits=split(/$/,”$line”);
my $i=0;
my $key;
foreach (@lsplits) {
if ($lsplits[$i] =~ /{([^}]+)}/) {
$key=$1;
while() {
if (exists $configHash{$key}) {
$lsplits[$i] =~ s/{[^}]+}/$configHash{$key}/ ;
if ($lsplits[$i] =~ /^${([^}]+)}/) {
$key=$1;
next;
}
last;
}
else {
$lsplits[$i]=””;
print “Error: Undefined Variable $key used in $dir/$envFileNamen”;
print “line: $line”;
last;
} } }
$i++; }
return join(”,@lsplits);
}