好吧,我有这行代码,我无法弄清楚,如果有人可以帮助我,这将是伟大的.我正在制作一个地理位置perl脚本作为我项目的一部分.
这是代码行
$isps = $info->{'isp'};
if ($isps = "Time Warner Cable")
{
print "Isp found, go to $website for more information\n";
}
if ($isps = "Google") {
print "Isp found, go to $website for more information\n";
} else {
print "No ISP located! No way of Contact via this terminal!";
}
Run Code Online (Sandbox Code Playgroud)
好吧基本上我正在尝试使if语句读取JSON代码并使其在列出特定名称时打印某些文本.我正在向文件添加更多的ISP,但现在只是这两个.
如果有人能用这行代码帮助我,因为我真的无法弄明白.
这=是赋值运算符.您想要字符串比较运算符eq.
在这一行要指定字符串"Time Warner Cable"的$isps变量.然后if-conditional看到字符串并将其解释为true.对于下一个条件相同.
if ($isps = "Time Warner Cable")
Run Code Online (Sandbox Code Playgroud)
相反,你想要:
my $isps = $info->{'isp'};
if ($isps eq "Time Warner Cable") {
print "Isp found, go to $website for more information\n";
}
elsif ($isps eq "Google") {
print "Isp found, go to $website for more information\n";
} else {
print "No ISP located! No way of Contact via this terminal!\n";
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
64 次 |
| 最近记录: |