perl q qq qr qw qx 区别与使用方法

1.q 相当于 单引号' '

   转义字符无效

     q可以使用()[] {} // ,,

2.qq 相当于" "

       转义字符有效

       qq可以使用()[] {} // ,,

3.qw  相当于 ('' ,'' ,' ')在每一个单词上添加 ' '

    转义字符无效

   qw可以使用()[] {} // ,,

         qq 和qw 区别,qq赋给数组是整体赋给数组的一个元素,而qw则会每个单词算作一个数组元素

4.qr   相当于创建正则

    qr//

5.qx 执行外部程序

    相当于``

 

复制代码
 1 #!/usr/bin/perl
 2 use strict;
 3 my $strq=q{\n\nthis is q test};
 4 my $strqq=qq,\n\nthis is qq test\n,;
 5 my @qw=qw /this is a qw             test \n/;
 6 my @qq=qq(this is qq           test \n);
 7 my $qr=/test/;
 8 my $qx=qx(date);
 9 print $strq;
10 print $strqq;
11 print "@qw";
12 print "\n";
13 print "@qq";
14 print "\nthis is qr test $qr\n" if($strq=~$qr);
15 print $qx;
复制代码

输出结果:

  

D:\>perl string.pl

\n\nthis is q test              

this is qq test
this is a qw test \n
this is qq test

this is qr test
The current date is: 2013/06/28 周五

posted @   to be crazy  阅读(14632)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示