Документация
HTML CSS PHP PERL другое

Section 3.5.  Underscores

 
Previous
Table of Contents
Next

3.5. Underscores

Use underscores to separate words in multiword identifiers.

In English, when a name consists of two or more words, those words are typically separated by spaces or hyphensfor example, "input stream", "key pressed", "end-of-file", "double-click".

Since neither spaces nor hyphens are valid characters in Perl identifiers, use the next closest available alternative: the underscore. Underscores correspond better to the default natural-language word separator (a space) because they impose a visual gap between the words in an identifier. For example:


    FORM:
    for my $tax_form (@tax_form_sequence) {
        my $notional_tax_paid
            = $tax_form->{reported_income} * $tax_form->{effective_tax_rate};

        next FORM if $notional_tax_paid  < $MIN_ASSESSABLE;

        $total_paid
            += $notional_tax_paid - $tax_form->{allowed_deductions};
    }

TheAlternativeInterCapsApproachIsHarderToReadAndInParticularDoesn'tGeneralizeWellToALLCAPSCONSTANTS:

    FORM:
    for my $taxForm (@taxFormSequence) {
        my $notionalTaxPaid
            = $taxForm->{reportedIncome} * $taxForm->{effectiveTaxRate};

        next FORM if $notionalTaxPaid  < $MINASSESSABLE;

        $totalPaid
            += $notionalTaxPaid - $taxForm->{allowedDeductions};
    }

    Previous
    Table of Contents
    Next
    © 2000- NIV