Perl中单引号和双引号之间的区别是什么?

Vij*_*jay 5 syntax perl interpolation

我刚开始学习Perl.我查看了开始的perl页面并开始工作.

它说:

单引号和双引号之间的区别在于单引号意味着它们的内容应按字面意思理解,而双引号意味着它们的内容应该被解释

当我运行这个程序时:

#!/usr/local/bin/perl
print "This string \n shows up on two lines.";
print 'This string \n shows up on only one.';
Run Code Online (Sandbox Code Playgroud)

它输出:

This string
 shows up on two lines.
This string
 shows up on only one.

我错了吗?perl的版本如下:

perl -v

This is perl, v5.8.5 built for aix

Copyright 1987-2004, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
Run Code Online (Sandbox Code Playgroud)

Iai*_*ins 15

我倾向于说你的shell /终端有什么问题,无论你输出什么,都将\n解释为换行符,而问题不在于Perl.

要确认:这不应该发生(TM) - 在第一种情况下我希望看到插入一个新行,但是使用单引号它应该输出字符\n不是新行.