Ugh! You're using %config both as input, for "variable values", thus containing strings. as for the output, in $config{'db'}, as a hash ref. My gut feeling tells me this, or something very similar, is the cause of your problem. You may have tried to use $config{'db'} as a string value first, which could well cause your problem.
Just put your input and output in different variables.
Comment on Re^3: Can't use string ("") as a HASH ref while "strict refs"