このことを考慮:
my $var = "${SOME_VAR}"
my $string "In this text ${SOME_VAR} will be replaced with X"
$string =~ s/$var/X/g;
print "\nprocessed string = <".$string.">";
戻り値
processed string = <In this text ${SOME_VAR} will be replaced with X>
つまり、置換は行われません。
ただし、$ varに予約文字($)が含まれていない場合、置換は実行されます。
my $var = "SOME_VAR"
/* everything else the same */
戻り値
processed string = <In this text ${X} will be replaced with X>
しかし、予約文字が変数内に含まれている場合、つまり検索トークンが明示的ではなくパラメーター化されている場合に、予約文字をエスケープする方法がわかりません。
何か案が?
ありがとう