1 All numbers in Perl have the same internal format, only double-precision floating-point numbers (there is no integer value inside perl).
2 Perl allows the use of underscores to delimit longer integers, such as 612980400283768 and 612_980_400_283_768 are the same values.
3 non-decimal integers in Perl: Octal begins with 0, 16 mechanism begins with 0x, binary begins with 0b.
4 The numeric operators in Perl include the modulo operator (%) and the exponential operator (* *), in addition to the subtraction. For%, the two operands first become the corresponding integer values, such as 10.5%3.2 first to be 10%3 and then computed. In a modulo operation, if one operand is negative, the result is related to the specific implementation of Perl. In addition, it is not usually possible to perform an operation with a negative number of math::complex (this will produce a plural) unless the module is available.
5 Single Quote string
Single quotes are not part of a string, but Perl can use it to identify the beginning and end of a string. Any character other than a single quotation mark or backslash (including a newline character, if the string continues on the next line) represents itself. To get a backslash, you can put two backslashes together; to get single quotes, you need to precede the single quotation mark with a backslash. The/n in a single quote string is not treated as a newline character, it is only two characters/and N. Only after the backslash is the/or single quote ' will be treated as a special character.
6 Double Quote String
/n is a newline character in the double quote string. Escape characters in double quotes:
------------------------------
Symbol | meaning |
------------------------------
|/n | change Line |
------------------------------
|/r | return |
------------------------------
|/T | tab |
------------------------------
|/F | formfeed |
------------------------------
|/b | backspace |
------------------------------
|/a | bell |
------------------------------
|/e | Escape (escape character in ASCII) |
------------------------------
|/007 | Any octal value (here is 007=bell) |
------------------------------
|/x7f | Any hexadecimal value (here is 007=bell) |
------------------------------
|/cc | A control character (here is CTRL + C) |
------------------------------
|//| anti-slash |
------------------------------
|/"| double quotes |
------------------------------
|/L | next character lowercase |
------------------------------
|/L | Next characters are lowercase until/e |
------------------------------
|/u | next Character Capital |
------------------------------
|/u | The next characters are all capitalized know/e |
------------------------------
|/q | Before Non-word character plus/, until/e |
------------------------------
|/e | end/L,/e and/q |
------------------------------
Another property of a double quote string is that it can be inserted into a variable, which means that when a string is used, if the string contains a variable name, it is replaced by the current value of the variable.
7 string operator
Strings can be connected by the. Operator.
The string repeat operator is a lowercase letter x, such as "Fred" x 3 # "Fredfredfred", 5 x 4 #实际上是 "5555".
8 automatic conversion between numbers and strings
Perl will automatically convert between numbers and strings based on operator characters between scalar values when needed.
9 of the scalar quantities in Perl are shaped like $fred. When a string is enclosed in double quotes, if the variable has no backslash before it, the value of the variable is replaced (if a variable is not assigned, a null value is used). Perl provides the delimiter {} to enclose variable names, such as:
$what = "Brontosaurus steak";
$n = 3;
Print "Fred ate $n $whats./n"; #输出不是steaks, but the value of $whats
Print "Fred ate $n ${what}s./n"; The value of the #现在使用 $what.
There are no Boolean types in Perl, but you can use a few rules to help your memory:
If the value is a number, 0 is false and the rest is true;
If the value is a string, the empty string (') is false and the rest is true;
If the type of the value is neither a number nor a string, convert it to a numeric value or string and then use the above rule.
11 Line input operator:<stdin>. <STDIN> is used as a scalar value, Perl reads the next line of text in standard input and passes it to <STDIN> each time. The use of the <STDIN> read string at the end of the line is a newline character, you can use the Chomp function to remove. Chomp is a function that, as a function, has a return value, the number of characters to remove. When using Chomp, you can use or not use (), which is also a common rule in Perl: unless they are removed, they change meaning, otherwise parentheses can be omitted. If there are two or more line breaks at the end, Chomp only removes one.
undef value
In Perl, a variable has a special value undef before the first assignment, and if the variable is a numeric type, undef is 0, and if it is a string, then Undef is an empty string.
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.