五、Perl条件语句

前端之家收集整理的这篇文章主要介绍了五、Perl条件语句前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
一、if语句
例如:
if ($name gt 'fred') {
	print "'$name' comes after 'fred' in sorted order.\n";
}
同样也有else:
if ($name gt 'fred') {
	print "'$name' comes after 'fred' in sorted order.\n";
} else {
	print "'$name' does not come after 'fred'.\n";
	print "Maybe it's the same string,in fact.\n";
}

二、while语句
例如:
$count = 0;
while ($count < 10) {
	$count += 2;
	print "count is now $count.\n";	# 程序将依次打印出2,4,6,8,10
}

猜你在找的Perl相关文章