in reply to dynamically creating variables

Why do you need to create new variables? They already appear to be in a hash, which is the data structure that is usually suggested when someone says they want variables with particular names. Perhaps I'm missing something.

Incidently, you're getting that error because you are trying to dereference a string (${$config} becomes ${ 'db' }, not the variable $db).

You can do what you're asking but it requires using soft (aka symbolic) references (perlref), which is usually a Bad Thing. See also Why it's stupid to use a variable as a variable name.

Update: added link to perlref

Replies are listed 'Best First'.
Re^2: dynamically creating variables
by Anonymous Monk on Nov 02, 2006 at 08:15 UTC
    Incidently, you're getting that error because you are trying to dereference a string (${$config} becomes ${ 'db' }, not the variable $db).

    Well, if $config contains the string db, ${$config} is a variable $db. It's not a lexical variable, but a package variable. Still, addressing it with $db works just fine (provided there isn't a lexical $db in the current scope).

    my $config = 'db'; ${$config} = 'foo'; print $db, "\n"; __END__ foo