Furthermore we were given exact input and an exact desired result. What additional detail could have made the question any clearer?
My attitude is that unless I am willing to provide an answer that I believe will be helpful, I won't answer. When the question indicates to me that the questioner may not know much Perl at all, my definition of a useful answer becomes very detailed. A higher level summary is OK when I think the questioner will understand it.
And a final note. Your answer had a severe error. You cannot possibly do exactly what the questioner requested using symbolic references. I'll leave it as an exercise for you to test and/or read documentation to discover why.