in reply to How to preserve values outside a sub

Your variable $params contains the same thing as $hashref, i.e. a reference to the anonymous hash referred to by $hashref. $params and $hashref are different variable, but they hold the same value, the address of the anonymous hash. Thus, modifying the data referred to by one means also modifying the data referred to by the other.