Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用perl将文件中的某些字符串替换为复杂的密码_Perl_Passwords - Fatal编程技术网

使用perl将文件中的某些字符串替换为复杂的密码

使用perl将文件中的某些字符串替换为复杂的密码,perl,passwords,Perl,Passwords,我想在bash脚本中使用perl将文本文件中的某些字符串替换为可能包含各种特殊字符(密码)的其他字符串。包含特殊字符的变量来自环境,因此我无法知道它们 比如说 # pw comes from the environment and I cannot be sure about it's content pw='%$&/|some!\!smart%(]password' pw=${pw//:/\\:} perl -p -e "s:PASSWORD:$pw:" <<< "

我想在bash脚本中使用perl将文本文件中的某些字符串替换为可能包含各种特殊字符(密码)的其他字符串。包含特殊字符的变量来自环境,因此我无法知道它们

比如说

# pw comes from the environment and I cannot be sure about it's content
pw='%$&/|some!\!smart%(]password' 
pw=${pw//:/\\:}
perl -p -e "s:PASSWORD:$pw:" <<< "my pw is: PASSWORD" # this would come from a text file
# yields: my pw is: %PASSWORD/|some!!smart%(]password
#pw来自环境,我不能确定它的内容
pw='%$&/|一些!\!智能%(]密码'
pw=${pw/://\\:}
perl-p-e“s:PASSWORD:$pw:使用适当的:

pw='%$&/|一些!\!智能%(]密码'
导出pw=${pw/://\\:}
perl-pe的:密码:$ENV{pw}:'