for (values %copy) { 1 while # repeat till no replacement left s/^($pattern)/$h_orig->{$1}/g; }