我认为grep的正则表达式和perl的正则表达式有所不同,我遇到了一个问题。请看下面的小测试:
$ cat testfile.txt
A line of text
SOME_RULE = $(BIN)
Another line of text
$ grep "SOME_RULE\s*=\s*\$(BIN)" testfile.txt
SOME_RULE = $(BIN)
$ perl -p -e "s/SOME_RULE\s*=\s*\$(BIN)/Hello/g" testfile.txt
A line of text
SOME_RULE = $(BIN)
Another line of text
如您所见,使用正则表达式"SOME_RULE\s*=\s*$(BIN)",grep能够找到匹配项,但perl无法使用相同的表达式来更新文件。我应该如何解决这个问题?