1. Perl converts a common variable into a scalar. This variable can refer to two types of direct quantities: Numeric direct quantities and string direct quantities.
A) String Representation Method:
Single quotes: the meaning of strings in single quotes is intuitive. Variable values and escape characters are not required;
Double quotation marks. The variable value and escape character value are required.
If you want to remove it, you usually need to add a backslash before it. The single quotation marks or double quotation marks are also required.
B) In addition, you can use qq or q to replace double quotation marks or single quotation marks, and the delimiters can be paired with (), <>,{}, [], and so on.
2. scalar Variables:
$ Add a variable name (array @, hash structure %); variable name is case sensitive; do not declare before using a scalar, but Initialization is required.
Some special scalar variables:
$ _, $ ", $/, $2, $, $! And their values are generally used as the "default value ". For example, $ _ is used as the default output value. $! Used as the default value of Error.
3. Expressions and operators:
1) Warning in Perl #! /Usr/bin/perl/-w, or use warnings;
2) Digit OPERATOR: Calculate the remainder % except/, and Power 4 ** 3 = 64
3) string OPERATOR: the concatenation operator ($ c = $ a. $ B;) can be used for the interpolation and replacement of variables in double quotation marks. If you cancel the replacement, add a backslash before $. Repeated operator x (for example, $ line = "_" x 7)
4) Name-based operators: int is an integer, length is a length, lc is converted to lowercase, uc is converted to uppercase, rand is a random number from 0 to the parameter value, cos, more perldoc
5). Angle brackets OPERATOR: <> Read a row from the handle. For example, <STDIN> reads a row from the keyboard of the standard input device, <FILE> reads a row from the FILE handle, and chomp $ line; delete the end line break.