$ENV{VARIABLE} = '/base/path'; $_ = '$ENV{VARIABLE}/my/path'; s/\$ENV\{(\w+?)\}/$ENV{$1}/g; print;