In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you what is the difference between single quotation marks and double quotation marks in perl, I believe most people do not know much about it, so share this article for your reference. I hope you will gain a lot after reading this article. Let's learn about it together.
The difference between double quotation marks and single quotation marks in perl
Difference one:
Single quotation marks except backslash characters and single quotation marks, all characters in single quotation marks represent themselves, for example, "\ t\ n" represents the string itself, that is,\ n inside single quotation marks is not a newline character, but represents two literal characters.
The backslash in double quotes is more powerful and can escape many control characters. "\ t\ n" in double quotes represents horizontal tabs and line breaks, respectively.
Print 'hello world\ t\ nprint "hello world\ t\ n"
Results:
Hello world\ t\ nhello world
Difference two:
Double quotation marks support variable interpolation, that is, the variable name in the string will be replaced with the current value of the variable, while single quotation marks do not support this feature and will be treated as a string.
My $string = "china"; print 'hello world $string'; print "\ n hello world $string"
Results:
Hello world $string hello world china
When perl checks the variable name, it may go against your will and treat the following string as part of the variable, causing the run result to fail to meet expectations; one way to avoid ambiguity is to surround the variable name with a pair of curly braces. For example:
My $fruit = "apple"; print "there are five ${fruit} s"
Single and double quotation marks in perl:
(1) there are pairs in pairs, and both of them need to be escaped.
(2) there is no need to escape if there is a single in a pair or a single in a single.
(3) the single quotation mark is straightforward, what is inside the quotation mark is displayed, and the double quotation mark needs to consider escape or variable substitution.
The above is all the content of this article entitled "what is the difference between single quotation marks and double quotation marks in perl". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.