串联需要在 Perl 中"space"?

  • 本文关键字:space Perl perl
  • 更新时间 :
  • 英文 :


没有从谷歌上找到任何关于这个问题的解释,尽管我可能没有使用正确的搜索词

script1:

#!usr/bin/perl
#concatenation2.pl
use warnings;
use strict;
print"Four sevens are",4*7 ,"n";
print"Four sevens are".4*7 ."n";

script2:

#!usr/bin/perl
#concatenation2.pl
use warnings;
use strict;
print"Four sevens are",4*7,"n";
print"Four sevens are".4*7."n";

script1的输出为:

Four sevens are28
Four sevens are28

好吧,所以我(学会了)在结束双引号之前需要有一个空格。然而,script2的输出最终会显示一条错误消息:

string found where operator expected at concatenate2.pl line 6, near "7."n""
(Missing operator before "n"?)
syntax error at concatenate2.pl line 6, near "7."n""

我在任何地方都找不到为什么数字和之间需要空格的解释。在script2中,我目前依靠谷歌和免费的perl书籍来帮助我学习语言。任何帮助(这类细微差别的一般指南)都将不胜感激。非常感谢。

7.perl lexer的数字,与3.1415926535类似。为了避免混淆,请用空格将点与前一位分开:"the answer is " . 4*7 . " times more complicated"

最新更新