#hash that contins the data %recordData = %$hashRef; #gets the email address $emailAddress = $recordData{ "EmailAddress" }; $message = $original_message; local($/) = undef; foreach $key (keys %recordData) { my $subVar = $recordData{$key}; my $subKey = "\$" . $key; # prints the data to the screen ( debugging ) print "$subKey = $subVar\n"; $message =~ s/\$subKey/$subVar/o; print "$message"; }