in reply to style q: duplication? of variables

Your suspicions are true that whenever passing a non-ref'd variable into or back out of a function, it makes a copy of what you were working with, be it a scalar, an array or a hash.

The most thorough way to squelch duplicates is to pass your variables in by reference. You can then modify the reference in place and you won't have to return anything. You can just manipulate the variable in-place.

returning a reference from a subroutine is often handy if you're creating something large and complex from scratch inside the subroutine. Forexample, a long Array of Hashes.