Perl Script Learning Notes Basics Tutorial

Source: Internet
Author: User
Tags delete key glob perl script
1. When chomp without parameters, the default parameters are used and the $_ operation is done.
2. Array @array ... Available $array[number] references. $ #array. Represents the number of indexes in an array.
3. $! contains error messages;
4. The default open file handle is "<" is input, ">>" and ">" The difference is a way to add the operation of the file.
if (@ARGV < 2) {
Die "Not Enough arguments\n";
}
5. Select LOG; change the default handle; You do not need to enter the handle parameter in the next output;
Print LOG "Hello world!\n";
6. Reopening a handle closes the previous file handle;
7. My @k = Keys%hash; My@v = values%hash return a key value or a variable value;
There is a key,delete function to delete key and value when exists function is judged in hask.
8. "." is the wildcard character of the metacharacters. The asterisk ("*") is the previous 0 or more times (simple quantifiers), "+" means one or more, "?" is to indicate that the occurrence does not occur once.
9. "/I" is not case-insensitive, "/s" matches any symbol, "/x" adds spaces, and "/is" is combined;
"m//" In fact represents the general pattern matching "//" can also use M (), M{},m<> Similar to "qw//".
11. The word boundary anchors, \b, is used for the word. such as/\bfred\b/can match the word Fred.
12.$1, such as the name of the same pattern, the matching of the parentheses in the logarithm of the item;
13. Three special variables ($ ', $&amp, $ ') to indicate where the matches are, respectively, to the left and right.
"/S" if not added "/g" can only be performed once;
15.unless is used on the contrary, and can form a statement immediately after the control modifier, elsif is not ElseIf, and an e is missing;
16.last and next correspond to the rest of the language and Continue;redo the next loop of the conditional expression to jump directly 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), found at the beginning, index returns 0. If one character is returned, it returns 1, followed by an analogy. If the substring does not exist, return -1;rindex ...
$part = substr ($string, $initial _position, $length);
20.my $money = sprintf "%.2f", 2.49997;
21.system "Date";
22.my (undef, $card _num, undef, undef, 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.