Perl Study Notes No. 5

Source: Internet
Author: User

1.> clear file data and overwrite;> append at the end of the file
2. It is recommended that you close a file handle immediately, regardless of whether the program ends immediately.
3. $! Indicates some readable information generated by the system, such as insufficient permissions and the file does not exist. The information contained in it is only valid when the system request fails.
4. As a general rule (die statement), if a usage error occurs, a line break is added to the message. If it is another error, you need to use it for debugging. Do not add a line break.
5. The removal of warn and die lies in that warn will not exit the program
6. Only Perl successfully reopens a new connection, otherwise the previous connection will not be closed.
7. Hash is similar to map in STL.
8. If the name is preceded by a dollar sign ($) followed by curly braces ({}), it is a hash element.
9: When a value is stored in an existing hash element, the previous value will be overwritten.
10. Access the nonexistent hash element to get UNDEF.
11. to reference the entire hash, use the percent sign ("%") as the prefix. % hash
12. assign values to the hash using the list. Key/value pairs are required. % hash = {"key", value, "key", value ...};
13. assign values to the list using hash, and the result is also a key/value pair. @ My = % hash;
14. You can directly copy the hash using the value assignment method.
15. If one hash is reversed and assigned to another, the key/value can be exchanged. Of course, it is best to ensure that the value is unique.
16. The reverse method is used for retrieval, which is good.
17. For Perl, The => and are the same.
18.-> used for reference.
19. bareword on the left of any large arrow symbol (=>) (a sequence consisting of letters, numbers, underscores, but not digits. It is preceded by an optional plus sign or minus sign) enclosed by quotation marks.
20. The keys function returns all the keys of the hash. The values function returns all values. If there is no element in the hash, the function returns an empty list.

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.