2
我想写一个循环,将确定用户输入是否匹配字符串$ rev。无论我为$ seq输入什么内容,它都会返回它不匹配,即使它实际上是。我究竟做错了什么?谢谢你的帮助。Perl - 简单的如果陈述不会工作
$seq = <>;
$rev = "string";
if ($seq eq $rev){
printf("The two strings match.\n");
}
else {
printf("The two strings do NOT match.\n");
}
你总是键入一个新行,但不要将其删除。 'chomp'。 – ikegami
如果您不需要'printf'的额外功能,则应该使用'print'。 – TLP