perl q qq qr qw qx 區別與使用方法

1.q 至關於 單引號' '數組

   轉義字符無效this

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

2.qq 至關於" "code

       轉義字符有效blog

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

3.qw  至關於 ('' ,'' ,' ')在每個單詞上添加 ' 'class

    轉義字符無效test

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

         qq 和qw 區別,qq賦給數組是總體賦給數組的一個元素,而qw則會每一個單詞算做一個數組元素perl

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 testThe current date is: 2013/06/28 週五

相關文章
相關標籤/搜索