Perl 编程/关键字/qw
外观
qw是一个可以用来替换引号(")符号的命令。
qw(element [element] […])
代码
my @array = qw(one two three);
print "Array contains " . @array . " element" . ((@array == 1) ? "" : "s") . "\n";
my @array1 = "only";
print "Array1 contains " . @array1 . " element" . ((@array1 == 1) ? "" : "s") . "\n";
my @family = "father, mother, daughter, son";
print "The family has " . @family . " member" . ((@family == 1) ? "" : "s") . "\n";
print qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)[2] . "\n";
返回数组中的元素数量和第三个月份,如下所示
Array contains 3 elements Array1 contains 1 element The family has 1 member Mar