Miller,
Hmmm. I guess I'm assuming that @keys will be defined, and I'm also assuming the $ref is a hash ref (although that seems a little less important).
Then, if I believe what I just wrote to be true, my first test should deal with whether or not @keys holds any data.
At that point, I...