更新时间:2023-11-14 11:35:28
语句$name = <STDIN>;
从标准输入中读取,并且包括终止换行符"\n
".使用chomp
函数删除该字符:
The statement $name = <STDIN>;
reads from standard input and includes the terminating newline character "\n
". Remove this character using the chomp
function:
print "What is your name?\n";
$name = <STDIN>;
chomp($name);
if ($name eq "Jon") {
print "We have met before!\n";
} else {
print "We have not met before.\n";
}