1,需要插入一个或多个变量,就使用双引号括住的字符串:
my $spam_name = "$title is good";
2,不想插入任何变量,就使用单引号括住的字符串:
my $spam_name = 'the title is good';
3,如果没有变量,本身包含单引号,改用q{...}的形式:
my $spam_name = q{the 'title' is good};
4,如果没有变量,本身又还包含不平衡大括号,改用中括号:
my $spam_name = q[the 'title is { good];
5,统一相关字符串时,统一格式加强可读性:
my $title = q[perl best];
my $pub = q[O'near];
my $end = q[}];
my $closing = q['}];
my $citation= qq[$title ($pub)];
转载于:https://blog.51cto.com/yanwang/1134913