[英]new to Perl - having trouble with a floating point comparison
I'm new to Perl, writing a simple script that checks to see if the installed version of VMware Fusion is greater than 8.4.我是 Perl 的新手,正在编写一个简单的脚本来检查已安装的 VMware Fusion 版本是否大于 8.4。 I'm getting this error:
我收到此错误:
syntax error at ./test.pl line 8, near ");"
This is the script:这是脚本:
@vmVersion = `defaults read /Applications/VMware\ Fusion.app/Contents/Info CFBundleShortVersionString`;
@vmMinimum = 8.4;
if($vmVersion > $vmMinimum);
then print "compliant";
else print "update required";
fi
That code you have isn't Perl.您拥有的代码不是 Perl。 Here's what might look more like Perl:
下面是看起来更像 Perl 的东西:
my $vmVersion = `defaults read '/Applications/VMware Fusion.app/Contents/Info' CFBundleShortVersionString`;
if ($vmVersion > 8.4) {
print "compliant";
} else {
print "update required";
}
Note two things:注意两点:
\\n
).\\n
)。 Without those, when a user runs your program, their prompt will print in a funny location afterwards.I've never seen我从没见过
if($vmVersion > $vmMinimum);
...
fi
In perl before, replace with block braces.在 perl 之前,用块大括号替换。
if($vmVersion > $vmMinimum) {
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.