我想寫一個嵌套的if語句的條件,但還沒有找到一個很好的例子使用或在if語句。下面elsif
條件失敗,並允許嵌套在它下面的代碼火災如果$status == 6
:我的Perl腳本中的if-elsif-else塊有什麼問題?
if ($dt1 > $dt2) {do one thing}
elsif(($status != 3) || ($status != 6)) { do something else}
else {do something completely different}
我想,以避免爲每個條件作爲實際居住在這裏的代碼中的另一個ELSIF是幾線長。
@mose:需要更多的上下文。你能提供更多的代碼嗎? – Dummy00001 2010-09-10 10:06:50
'($ status!= 3)|| ($ status!= 6)'總是如此。 – flies 2010-09-10 14:53:12
** @蒼蠅:**如果狀態爲「undef」,該怎麼辦? – vol7ron 2010-09-10 17:37:54