我正在创建一个小程序来查找特定的哈希键并替换其源,但为此我需要找到整个哈希并将其替换为用户输入的值的新哈希。
我的代码示例。
print "Please input the smile you would like to edit: ";
$EditSmile = <STDIN>;
print "Please input the text you want to change: ";
$EditText = <STDIN>;
open (IN, "< info.pl") || die("Can not open file: $!");
while (<IN>){
$var1 =~ s/\'$EditSmile\' => "$smileinfo{"$EditSmile"}"/\'$EditSmile\' => "$EditText"/g;
print $var1;
}
哈希值在文件中的位置info.pl
,该文件包含在程序中。