http://www.perlmonks.org?node_id=174865

Angel has asked for the wisdom of the Perl Monks concerning the following question:

Ok getting hammered by something that should not be that difficult again. I want to take a hash and substitute the keys with $keyname from a text file and place the hash value in it's place. I tried and tried and I cant get it to do the substitution
#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"; }
any clue on how to get this to work?