for (keys %oldhash) { # change key and keep the value $oldhash{utf8_on($_)} = delete $oldhash{$_}; } call_pyfunc(\%oldhash);