$text =~ s/\$(\w+)/$$1 * 2/egx; #I tried to double the age and succeeded!