关于一个 =~ s///g的问题

关于一个 =~ s///g的问题

关于一个 =~ s///g的问题
比如
我赋值

$a = moon;
然后我想让所有moon都替换为a
$talk{msg} =~ s/$a/a/g;
$talk{msg} =~ s/[$a]/a/g;
$talk{msg} =~ s/[$a]{4}/a/g;

以上都是不行
是不是s///g不能替代$函数呢?

这里moon只是一个例子,实际是截取获得一个$1
然后$a = $1;

所以不能确切的写替代内容

求助吖
主要问题就是--$a = $1<.
主要问题就是
$a = $1

if ($talk{msg} =~ m/^(\^[A-Za-z0-9]{6})(.)\^[A-Za-z0-9]{6}(.)\^[A-Za-z0-9]{6}(.)\^[A-Za-z0-9]{6}(.)\^[A-Za-z0-9]{6}(.)(\^[A-Za-z0-9]{6})(.)\^[A-Za-z0-9]{6}(.)\^[A-Za-z0-9]{6}(.)\^[A-Za-z0-9]{6}(.)\^[A-Za-z0-9]{6}(.)(\^[A-Za-z0-9]{6})(.)\^[A-Za-z0-9]{6}(.)\^[A-Za-z0-9]{6}(.)\^[A-Za-z0-9]{6}(.)\^[A-Za-z0-9]{6}(.)/) {

if ($checktimes == 0) {
$aaaa = "$1$2";
$bbbb = "$7$8";
$cccc = "$13$14";
message "chk1b是$aaaa\nchk2b是$bbbb\nchk3b是$cccc\n","schat";
########
$talk{msg} =~ s/$aaaa/A/g;
$talk{msg} =~ s/$bbbb/B/g;
$talk{msg} =~ s/$cccc/C/g;
message "$talk{msg}\n","info"
##########
}
楼上的是研究OpenKore的么.
楼上的是研究OpenKore的么, 现在2.0刚出来吧.....怀念做破解反外挂脚本的日子...


my $a = "moon";
my $msg = "moon is moon";
$msg =~ s/$a/a/g;
print $msg; # a is a
不知道LZ的问题是什么.

应该是$1的问题吧,$1是个特殊的变量
比如下面的代码
my $test = 'this is a book';

$test =~ s/(\w+)/that/;

print "$test \n";

print "$1\n";

#===================================

$a = $1;

my $test = 'this is a book';

$test =~ s/$a/what/;

print "$test \n";

print $a;

结果是:
that is a book
this
what is a book
this




   

[quote]回复给 jindadong .
[quote]回复给 jindadong : 关于一个 =~ s///g的问题...[/quote]

这段代码运行一切正常, 你想问$1什么呢?

my $test = 'this is a book';
$test =~ s/(\w+)/that/;
print "$test\n";
print "$1\n";

my $a = $1;
$test = 'this is a book';
$test =~ s/$a/what/; ### =~ s/this/what/;
print "$test\n";
print $a;