Sounds like you've put in a bit of work on figuring this out, so I won't cheat you out of that burst of pleasure that comes from solving a problem yourself. (I.e., a hint is all you're gonna get.)
Take a look at perlre, and note which of the regular expression "modifiers" change what '.' will match.