It's easy to do that kind of thing with hash lists:
$myhash['set_variable'] = "variable";
$myhash['dynamic_variable'] = "_extension";
$myhash2[$myhash['set_variable'].$myhash['dynamic_variable']] = "...
would give
$myhash2['variable_extension'] = "...
Not really sure if variable values can be used to set variable names, not sure why you'd want to either 🙂