Some knowledge about Perl scalars and operators _perl

Source: Internet
Author: User
Tags scalar

1.Perl the general variable into a scalar, the variable can refer to the direct amount of two kinds: the number of direct volume, string direct.

A) The string representation method:
Single quotes, the strings in single quotes are intuitive and do not require variable values and escape characters;
Double quotes requiring variable values and escape character values.
If you need to eliminate it, you usually need to add a backslash in front of it, either single or double quotes.

B In addition, QQ or q can be used instead of double quotes or single quotes, the boundary character can be used in pairs (), <>, {}, [] and so on.

2. Scalar variables :

$ plus variable name (array using @, hash structure using%); variable names are case-sensitive; you do not need to declare them before using a scalar but initialize them.

Some special scalar quantity:
$_, $ ", $/, $, $$, $! , their values are usually used as "default values." If the $_ is used as the default value for the output, $! is used as the default value for the error.

3. Expressions and Operators :

1), the warning #! in Perl /usr/bin/perl/-W, or use warnings;
2), the number operator: except/, the remainder%, take power 4**3=64
3, string operator: the operator of the $c = $a. $b;) The interpolation substitution of the variable in double quotation marks can also be used for the insert operation, if the $ is canceled before the backslash is added. Repeat operator x (such as $line = "_" x 7)
4), with the name of the operator: int to take the integer part of length, LC conversion to lowercase, UC conversion to uppercase, Rand from 0 to the random number of parameter values; Cos, more Perldoc
5), the angle bracket operator:<> a row in the handle, for example, <STDIN> reads a row from the keyboard of a standard input device and reads one row,<file> from a file handle, chomp $line; Deletes the end line break.

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.