sub substitute_vars { my ($template, $hash) = @_; (my $out = $template) =~ s/\${([^}]+)}/$$hash{$1}/ge; $out; }