Perl Best Practices (excerpt)---06

Source: Internet
Author: User

The sixth chapter: Control structure 0 LU Ii.

Use the code block if, and do not use the suffix if.

For example, the following is not a good idea:

$sum + = $measurement if defined $measurement;

In fact, it equals:

if (defined $measurement) {

$sum + = $measurement;

} 0 on three continents.

The suffix if is to be persisted to the process Control statement. 0 Land establishments.

do not use unless, for, while, and until as suffixes. 0 Lu Wu.

Never use unless or until. 0 Land and land.

avoid C-style for statements. 0 Land Seven.

avoid indexing arrays or hashes within a loop. 0 Land Ba.

never mark an index more than once in a loop. 0 Lu Ying.

use a noun-method variable as a for loop iterator. 0 Qi 0.

always declare a for loop iterator with my. 0 Qi One.

to create a new list from the old list, use map instead of for. 0 Qi Ii.

to find the values in the list, use grep and first, not for. 0 Qi Three.

to convert the list, use for, not map. 0 Qi Restaurant.

use subroutine calls to separate complex list conversions. 0 Qi Wu.

never modify $_ in a list function. 0 Qi Lu.

avoid cascading if. 0 Qi Qi.

the use of table lookups is preferred when cascading equality tests. 0 qi Ba.

A ternary expression that uses a tabular format when a value is generated. 0 Qi Jiu.

do not use do...while loops. 0 BA 0.

reject loop iterations as much as possible and as early as you can. 0 ba.

do not distort the loop structure for the sake of concentration control. 0 ba.

use for and redo, do not use the irregular count while. 0 ba three.

label Each loop that will explicitly leave,

The label is then used for each next, last, and redo.

Perl Best Practices (excerpt)---06

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.