<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 四個假值 在 Perl 中有 4 種假值: ~~~ my $false = undef; $false = ""; $false = 0; $false = "0"; ~~~ 最后一個為假值是因為?`"0"`?在數字上下文中將變成 0,根據第三條規則, 它是假值。 ## 后綴控制 簡單的?`if`?或?`unless`?塊可能看起來像這樣: ~~~ if ($is_frobnitz) { print "FROBNITZ DETECTED!\n"; } ~~~ 在這些情況下,`if`?或?`unless`?能夠追加到簡單語句的尾部。 ~~~ print "FROBNITZ DETECTED!\n" if $is_frobnitz; die "BAILING ON FROBNITZ!\n" unless $deal_with_frobnitz; ~~~ `while`?和?`for`?也可以這樣用。 ~~~ print $i++ . "\n" while $i < 10; ~~~ ## `for`?循環 `for`?循環有三種風格。 ~~~ my @array; # Old style C for loops for (my $i = 0; $i < 10; $i++) { $array[$i] = $i; } # Iterating loops for my $i (@array) { print "$i\n"; } # Postfix for loops print "$_\n" for @array; ~~~ 你也許會看到?`foreach`?用于?`for`?的位置。它們兩個可以互換。在上述后 兩種循環風格中多數人使用?`foreach`。 ## `do`?塊 `do`?允許 Perl 在期待語句的位置使用塊。 ~~~ open( my $file, '<', $filename ) or die "Can't open $filename: $!" ~~~ 但如果你需要做別的事: ~~~ open( my $file, '<', $filename ) or do { close_open_data_source(); die "Aborting: Can't open $filename: $!\n"; }; ~~~ 下列代碼也是等價的: ~~~ if ($condition) { action(); } do { action(); } if $condition; ~~~ 作為特殊情況,`while`?至少執行塊一次。 ~~~ do { action(); } while action_needed; ~~~ ## Perl 沒有?`switch`?或?`case` 如果你從其他語言而來,你可能用過?`case`?語句。Perl 沒有它們。 最接近的我們有?`elsif`: ~~~ if ($condition_one) { action_one(); } elsif ($condition_two) { action_two(); } ... else { action_n(); } ~~~ 沒有辦法像?`case`?那樣清晰。 ## `given ... when` 從 Perl 5.10.1 開始,你可以使用下列代碼來打開實驗性的?`switch`?特性: ~~~ use feature "switch"; given ($var) { when (/^abc/) { $abc = 1 } when (/^def/) { $def = 1 } when (/^xyz/) { $xyz = 1 } default { $nothing = 1 } } ~~~ ## `next/last/continue/redo` 考慮以下循環: ~~~ $i = 0; while ( 1 ) { last if $i > 3; $i++; next if $i == 1; redo if $i == 2; } continue { print "$i\n"; } ~~~ 輸出: ~~~ 1 3 4 ~~~ `next`?跳到塊尾并繼續或重新開始。 `redo`?立即跳回到循環的開頭。 `last`?跳到塊尾并阻止循環再次執行。 `continue`?在塊尾執行。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看