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 周五