in reply to using $1 in a hash?

In your second example, $1 and $2 are not set at the time you're creating the %translation hash. Those are only set after a successful capturing match.

Rather than help you with the regex, I think I'd rather pont you at Config::Inifiles, which may do most of the task for you.