Reference webpage: </P> <p> http://man.ddvip.com/web/perl/perl1.htm </P> <p >#======================= =====================================================< br/> # variable add $ above; <br/> #0 headers in octal; 0x headers in hexadecimal format; <br/> $ value1 = 047; <br/> $ value2 = 0xff; <br/> #=============================================== ====================================< br/>#==================== ========================================================== =======< br/> # output mode <br/> Print ("print number ", $ value, "/N"); <br/> Print ("$ string", "/N"); <br/> Print ("$ string $ value/N "); <br/> #=============================================== ======================================</P> <p >#============== ========================================================== ============< br/> # floating point registers generally cannot precisely store floating point numbers, this produces errors. Pay special attention to these errors during calculation and comparison. The index ranges from-309 to + 308. <Br/> #=============================================== ======================================< br/> #! /Usr/local/bin/perl <br/> $ value = 9.01e + 21 + 0.01-9.01e + 21; <br/> Print ("first value is", $ value, "/N") ;###### 0 <br/> $ value = 9.01e + 21-9.01e + 21 + 0.01; <br/> Print ("second value is", $ value, "/N "); ##### 0.01 <br/>#============================ ===============================</P> <p >#==== ========================================================== ======================< br/> # strings in double quotation marks support replacement of simple variables <br/> $ number = 11; <br/> $ Tex T = "This text contains the number $ number. "; <br/> #=============================================== ======================================< br/>#================== ========================================================== ==========< br/> there are two differences between a single quotation mark string and a double quotation mark string, first, there is no variable replacement function, and second, the backslash does not support escape characters, but only takes effect when it contains single quotes and backlash. Another feature of single quotes is that it can span multiple rows, such as: <br/> $ text = 'this is two <br/> lines of text <br/> '; <br/> equivalent to the following sentence: <br/> $ text = "This is Two/nlines of text/N "; <br/> #=============================================== ======================================< br/>#================== ========================================================== =======< br/> $ string = "43 "; <br/> $ number = 28; <br/> $ result = $ string + $ number; # $ result = 71 <br/> If the string contains non-numeric characters, from the left to the first non-numeric character, for example: <br/> $ Result = "hello" * 5; # $ result = 0 <br/> $ result = "12a34" + 1; # $ result = 13 <br/>#============================== ===============================</P> <p >#==== ========================================================== ======================< br/> + (ADD) ,-(subtraction), * (multiplication),/(Division), ** (multiplication power), % (remainder),-(single object negative) <br/> operator <=> result: <br/> 0-two values are equal <br/> 1-the first value is greater <br/> 1-the second value is greater <br/>#====== ========================================================== ================< br/> logical or: $ | $ B or $ A or $ B <br/> logic and: $ A & $ B or $ A and $ B <br/> logic not :! $ A or not $ A <br/> logic is different or: $ a XOR $ B <br/>#============================== ========================================< br/> bit and: & <br/> bit or: | <br/> bit is not :~ <Br/> bitwise exclusive or: ^ <br/> shift left: $ x <1 <br/> shift right: $ x> 2 <br/> note: do not use & for negative integers, because Perl will convert them into unsigned numbers. <Br/> #=============================================== ======================================< br/> join :. <br/> duplicate: x <br/> join and assign values (similar to + = ):. = <br/> example: <br/> $ newstring = "potato ". "head"; <br/> $ newstring = "T" x 5; <br/> $ A = "be"; <br/> $. = "witched "; # $ A is now "Bewitched" <br/>#======================== ===================================< br/>#==== ========================================================== ======================< br/> # comma operator, note that brackets should be added <Br/> $ val = 26; <br/> $ result = (++ $ Val, $ Val + 5 ); # $ result = 32 <br/>#============================== ===============================< br/>#======== ========================================================== ================< br/> # condition operators <br/> are similar to those in C, condition? Value 1: Value 2. If the condition is true, the value 1 is used. If the condition is false, the value 2 is used. For example: <br/> $ result = $ Var = 0? 14: 7; <br/> $ result = 43 + ($ divisor = 0? 0: $ dividend/$ divisor); <br/> in Perl 5, you can also use the conditional operator on the left of the assignment type to select the variable to be assigned, for example: <br/> $ condvar = 43? $ Var1: $ var2 = 14; <br/> $ condvar = 43? $ Var1 = 14: $ var2 = 14; <br/> #=============================================== ======================================