Perl script learning notes

Source: Internet
Author: User
Tags glob perl script

1. When chomp does not have a parameter, use the default parameter to operate on $.
2. array @ array .. can be referenced by $ array [number. $ # Array... indicates the number of indexes in the array.
3. $! Contains error information;
4. By default, the file handle is opened by "<", that is, input. The difference between ">>" and"> "lies in the operation of adding a file handle. Composition Parts.
If (@ argv <2 ){
Die "not enough arguments \ n ";
}
5. Select log; change the default handle; you do not need to enter the handle parameter for subsequent output;
Print log "Hello world! \ N ";
6. opening a new handle will close the previous file handle;
7. My @ k = keys % hash; my @ v = values % hash return key value or variable value;
The exists function in hask determines that a key exists. The delete function deletes the key and value;
8. "." is a metacharacter wildcard. The asterisk ("*") matches the first item zero or multiple times (simple quantifiers). "+" refers to one or more ,"? "Yes indicates not to appear once.
9. "/I" is case-insensitive; "/s" matches any symbol; "/X" adds a space; "/is" is used together ";
10. "m //" actually represents the normal pattern matching "//" you can also use M (), m {}, m <> .. similar to "QW //".
11., \ B, is used for words. For example,/\ bfred \ B/can match the word Fred.
12. $1, $2 is the same as the matching item in the logarithm of brackets in the pattern;
13. The three special variables ($ ', $ &, $') are used to indicate where the match is located, which are left, right, and right.
14. "/s" can be executed only once without "/g;
15. Unless and if are used on the contrary. At the same time, a statement can be formed immediately after the modifier is controlled. elsif is not an elseif statement, but an E is missing;
16. The break and continue of other languages corresponding to last and next. The next loop of redo without a conditional expression directly jumps to the top of the loop content.
17. unlink "file"; rename "old", "new"; Link "file"; mkdir "file", OCT ("permission"); rmdir "file"; chmod 0755, "Fred", "Barney"; chown $ user, $ group, glob "*. O "; utime $ now, $ ago, glob" * ";
18. Index... $ where = index ($ big, $ small); the index returns 0 if it is found at the beginning. If a character is followed, 1 is returned, and so on. If the substring does not exist,-1; rindex... is returned...
19. $ part = substr ($ string, $ initial_position, $ length );
20. My $ money = sprintf "%. 2f", 2.49997;
21. System "date ";
22. My (UNDEF, $ card_num, UNDEF, $ count) = Split /:/;
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.