my %CHANGE = ( ':-)' => 'happy', ':-(' => 'sad', ); my $text = "I am :-) but sometimes I am :-(."; for my $out ( keys %CHANGE ){ my $in = $CHANGE{$out}; $text=~s/\Q$out\E/$in/sg; # need to use \Q \E for quoting # $text=~s/$out/$in/sg; # <- this will go bonkers, it will # treat $out as a regex, not a string } print $text; # output: I am happy but sometimes I am sad.