Perl Learning: 2.9. The while Control Structure
来源:互联网 发布:京东和淘宝买吉他 编辑:程序博客网 时间:2024/06/03 21:40
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.
- Perl Learning: 2.9. The while Control Structure
- Perl Learning: 2.6. The if Control Structure
- Learning Perl: 3.6. The foreach Control Structure
- Learning Perl: 10.1. The unless Control Structure
- Learning Perl: 10.2. The until Control Structure
- Learning Perl: 10.4. The Naked Block Control Structure
- Learning Perl: 2.8. The chomp Operator
- Perl Learning: 2.10. The undef Value
- Learning Perl: 2.11. The defined Function
- Learning Perl: 4.8. The use strict Pragma
- Learning Perl: 4.9. The return Operator
- Learning Perl: 5.3. The Invocation Arguments
- Learning Perl: 8.4. The Binding Operator, =~
- Learning Perl: 8.6. The Match Variables
- Learning Perl: 9.2. The split Operator
- Learning Perl: 9.3. The join Function
- Learning Perl: 10.5. The elsif Clause
- Learning Perl
- Learning Perl: 2.8. The chomp Operator
- 笔记
- C++ CFile::Rename 出现“拒绝访问”异常 及解决方案(不能说原创,自己悟出来的)
- JAVA的内省机制(introspector)与反射机制(reflection)
- 无电池的情况下,如何升级DELL INSPIRON 6400的bios
- Perl Learning: 2.9. The while Control Structure
- Perl Learning: 2.10. The undef Value
- Learning Perl: 2.11. The defined Function
- A
- CSS控制排版(转载)
- Learning Perl: 2.12. Exercises
- LINUX上安装memcached
- Java异常框架中finally执行、及其他相关问题
- Struts2开发知识点