Perlについての質問箱 3箱目
■ このスレッドは過去ログ倉庫に格納されています
0583デフォルトの名無しさん
NGNG$str = '\100';
print "str: $str";
$str =~ s/\\/\\\\/g;
print "str: $str";
# 実行結果
# str: \100
# str: \\100
#★これも納得できる。
my $pre = '\\\\';
my $after = '\\\\';
print "pre : $pre";
print "after: $after";
# 実行結果
# pre : \\
# after: \\
#★これが納得いかない。
# 変数に入れた場合は、置換後の文字列をエスケープしなくていいの?
$str = '\100';
print "str: $str";
$str =~ s/$pre/$after/g;
print "str: $str";
# 実行結果
# str: \100
# str: \\100
■ このスレッドは過去ログ倉庫に格納されています