加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Perl Learning: 2.9. The while Control Structure

发布时间:2020-12-15 20:57:01 所属栏目:大数据 来源:网络整理
导读:? 2.9. The while Control Structure Like most algorithmic programming languages,Perl has a number of looping structures. [ ] The while loop repeats a block of code as long as a condition is true: [ ] Every programmer eventually creates an i

Previous Page

Next Page

?

2.9. The while Control Structure

Like most algorithmic programming languages,Perl has a number of looping structures.[

] The while loop repeats a block of code as long as a condition is true:

[

] Every programmer eventually creates an infinite loop by accident. If your program keeps running and running,you can generally stop it in the same way you'd stop any other program on your system. Often,typing Ctrl-C will stop a runaway program; check with your system's documentation to be sure.

    $count = 0;
    while ($count < 10) {
      $count += 2;
      print "count is now $count/n"; # Gives values 2 4 6 8 10
    }

As always in Perl,the truth value here works like the truth value in the if test. Like the if control structure,the block curly braces are required. The conditional expression is evaluated before the first iteration,so the loop may be skipped completely if the condition is initially false.

Previous Page

Next Page

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读