The problem isn't the anonymous hash, the problem is the atomic assignment. That is, you're simultaneously assigning a value to $key, and trying to use the new value of $key as a key. Instead, you're getting the old value of $key, which is why all your data is off by one. I can't think of a way to do it in one line, since you really are making two assignments where the second depends on the first.
Comment on Re: Splitting file data in to anonymous hashes