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. 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. Here's what might look more like 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
). 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.
if($vmVersion > $vmMinimum) {
...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.