My first guess is that you return the data structure you just edited in place for some reason. Keep in mind that Perl return the last evaluated expression if there's no return statement. Try putting a return; as the last line in the sub. Without code to look at, there's not much more specific anyone can say. Sorry if this isn't the source of your troubles.