Perl language learning notes 10 other control structures

Source: Internet
Author: User

1. Unless control structure

Execute when the condition is false, opposite to if

Else can be attached.

2. Until control structure

If the condition is false, it is executed until the condition is true;

3. Conditional Modifiers

The effect is equivalent:

Similar mode:

4. Bare block control structure

{

Body;

Body;

....

}

Helps to define valid ranges for temporary variables

5. elsif clause

6. Auto-increment and auto-Increment

Same as C Language

7.

Same as C Language

8. For and foreach

In Perl, the two are equivalent, and the pure foreach is preferred.

9. 5 types of cyclic blocks: For, foreach, while, until, and bare Block

Last is equivalent to break in C language, and next is equivalent to continue in C language.

Redo: Re-execute this iteration

10. Tagged Block

Place the label and a colon in the front of the loop. It is recommended that all labels be capitalized;

The tag is used to name the entire code. When necessary, add this tag behind last, next, and redo.

11. Three-object Operator

? : Conditional expression? True expression: false expression

Multiple branches can be written:

12. logical operators

&, |: Consistent with the C language usage

13. Short-circuit Operator

If the value on the left of "|" is false, the value on the right is assigned to $ last_name;

14. "define no" OPERATOR ://

If the value on the left of "|" is a false value, the value cannot be assigned correctly;

No matter whether the value on the left of "//" is true or false, if it has been defined, it is assigned to $ last_name;

15. Word writing

Logic and (&, and), logic or (|, or)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.