$string =~ s/$pat/$$ref/g;