scalar data
All numbers have the same format internally: there are no integer values internal to perl.
Non-Decimal integer literals:
Octal(base 8): 0377 #377 octal, same as 255 decimal (leading zero)
Hexadecimal(base 16): 0xff #FF hex, also 255 decimal
Binary(base 2): 0b11111111 #also 255 decimal
Perl allows underscores for clarity within the literals.
运算符:
%: modulus operator
Strings: literal strings come in two different flavors, single-quoted string literals and double-quoted string literals
Any character other than a single quote or a backslash between the quote marks (including newline characters, if the string continues onto successive lines) stands for itself inside a string. Backslash takes on it’s full power to specify certain control characters. When a string literal is double-quoted, it is subject to variable interpolation (变量内插)besides being checked for backslash escapes.
The simplest way to get a value from the keyboard into a perl program is to use the line-input operator <STDIN>.
The chomp operator: chomp($name). If the string ends in a newline character, chomp can get rid of the newline. The most common use of chomp is: chomp($name=<STDIN>). chomp is a function, has a return value, which is the number of the characters removed. If a line ends with two or more newlines, chomp removes only one. If there is no newline, it does nothing and returns zero.
The undef value and the defined function: variables have the special undef value before they are first assigned. But undef is neither a number nor a string; it is an entirely seperate kind of scalar value. To tell if a value is undef and not the empty string, use the defined function, which returns false for undef and true for everything else.