I am trying to do a substitution of some variables into a string. The hash contains the data, the $name string is the format. It will put in two of the variable but not the %M one. I am baffled. I have tried two different signal characters and also substitutes with and without spaces. The %M does not go in. ????
use Data::Dumper;
my %Sub = (A=>'Alan',G=>'42', M=>"Memories of Japan");
print "\%Sub=\n".Dumper(%Sub)."\n====\n";
my $name = "#M #A (#G).epub";
print "$name\n====\n";
$name =~ s/(#([AGM]))/($Sub{$2})/eeg;
print "$name\n====\n";
%Sub = (A=>'Bob',G=>'13', M=>'NightHawk');
print "\%Sub=\n".Dumper(%Sub)."\n====\n";
$name = "%M %A (%G).epub";
print "$name\n====\n";
$name =~ s/(%([AGM]))/($Sub{$2})/eeg;
print "$name\n====\n";