next up previous contents
Next: 條件比較 Up: Bourne shell, perl與C語法比較 Previous: 陣列與Hash   Contents

條件敘述

shell
	if test; then
		dosomething
	elif test; then
		doother
	else
		allright
	fi
perl
	if (c) {
		do_something;
		
	} elsif () {
		do_other;
	} else {
		allright;
	}
C
	if (c) {
		do_something;
	} else if () {
		do_other;
	} else {
		allright;
	}
這邊要注意的是shell不需要括號,else if的寫法三個不一樣。條件式寫法, shell沒有一定要用()包住條件式,只要test是某個可執行的敘述就好

Subsections

Cyril Huang 2002-06-14