You can definitely do that; you are using soft references in creating the variables $$name (note that you don't even need the extra {}.) Sometimes this is frowned upon, but in a small
program it seems OK. (I've done that to create variables from form input in a cgi.)
chas