Q,qw,qr,qx,qq__perl in the PERL language

Source: Internet
Author: User
In the Perl language, there are two special and commonly used symbol QQ QW, respectively, explained as follows:
Qq{foobar} meaning for double quote string, interpolation variable
The equivalent of "Foobar"
Qw{foo Bar} means to decompose a string with a space and get a list, equivalent to the following statement
The result of Split (', ' foo Bar ') is ' foo ', ' Bar '

String comparisons are equivalent to using EQ

Q operator's way of escaping the ' number '
$someword = ' i \ ' ve some money ';
can be equivalent to:
$someword = Q~i ' ve some money~;

QQ operator for "Number escape mode"
$someword = "I say \" ok!\ "."
can be equivalent to:
$someword = Qq~i say "ok!". ~;

The QW represents a space to separate the elements to get the list
@list = ("Perl", "Regular", "Network", "Web");
can be equivalent to:
@list = QW (perl Regular Network web);

QR representatives create regular
$myword = "Catcat";
$replaceword = QR (catcat);
$finalword = "OK" if ($myword =~ $replaceword);

The quotation mark execution operator (quoted execution operator), qx//

Q and QQ operator features:
※q and QQ must be an identifier, not a part of the identifier. For example:
Q (ABC) used () as a delimiter
Q (ABC) used () as a delimiter
Q XABCX with X as a delimiter
are legal, and
QXABCX would be treated as an identifier, and who would have thought that Qxabcx was actually a Q-op.

The ※Q and QQ spaces do not affect syntax, but any non-null characters (not spaces, not TAB characters,
is not a newline character, it is used as a boundary.

※ If Q and QQ use some special symbols, they must be paired. For example,:< only and >; To be together
Used as a boundary character, not just two < as a boundary character. and | It can only be a pair of boundaries with itself.
The limit character. These special symbols are: (), {}, [], <>;

$myword = "Catcat";
$replaceword = QR (catcat);
$finalword = "OK" if ($myword =~ $replaceword);

@list = ("Perl", "Regular", "Network", "Web");
can be equivalent to:
@list = QW (perl Regular Network web);

$someword = ' i \ ' v some money ';
can be equivalent to:
$someword = Q~i ' v some money~;
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.