Okay. Thought it might have been a typo :-)
So, your tests show that in the development environment, $dsn expands to DBI:mysql:database=foo;port=3308 (which is what you seem to want), yet the wrong database is being updated. If that is correct, I don't know what's wrong; the perl up to here is fine.
Sorry.