以下示例演示了各种类型的字符串标量的用法。注意单引号字符串和双引号字符串之间的区别-
#!/usr/bin/perl $var = "这是字符串标量!"; $quote = 'I m inside single quote - $var'; $double = "This is inside single quote - $var"; $escape = "This example of escape -\tHello, World!"; print "var = $var\n"; print "quote = $quote\n"; print "double = $double\n"; print "escape = $escape\n";
输出结果
这将产生以下结果-
var = 这是字符串标量! quote = I m inside single quote - $var double = This is inside single quote - 这是字符串标量! escape = This example of escape - Hello, World