Perl Study Notes No. 10

Source: Internet
Author: User

1. Unless statement, if is executed when the condition is true, unless is executed when the condition is false

2. abbreviation statement. & error ("invalid input") Unless & valid ($ input); $ I * = 2 unitl $ I> $ J; print "", ($ n + = 2) while $ n <10; & Greet ($ _) foreach @ person;

3. the bare block, which usually provides scope for temporary variables.

4. Although there is no switch, we have elsif. Note that it is neither else if nor elseif.

5. Calculate the square root of SQRT

6. Use last to exit the loop, similar to break; next and continue...

7. Redo, it will be adjusted to the top of the current loop block, without the conditional expression judgment and the functionality of this loop...

8. You can add tags to the outer loop and jump out of the loop... powerful! It also means goto is more =. =

9. Put the judgment of whether the divisor is 0 on the left of the & operation, which can be used to prevent the divisor from being 0... this method is good... short-circuit operation

If ($ n! = 0 & $ total/$ n <10 )...

10. In Perl, short-circuit operations do not always return true/false, for example, my $ last_name = $ last_name {$ someone} | 'no last name ';

If $ someone is not in hash, assign a value...

11. The usual method to open a file in Perl is:

Open chapter, $ filename or die "can't open '$ filename': $! ";

 

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.