I was thinking just the same as you. But there's some tiny bugs. First, it should be @rec{@keys}. No scalar sigil. Second, having another delimiter than / in a regex often mean that you might forget a trailing delimiter if the last char in the pattern is a slash. That's the case here. You forgot the last colon.
It could also be worth to mention the special behaviour for $/ = "".