my $db_str = '$ENV{INP_DIR}'; $db_str =~ s/\$ENV\{([^}]*)\}/$ENV{$1}/ge; print $db_str;