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";
The output for script1 is:
Four sevens are28
Four sevens are28
Okay, so I (learned that) need to have a space before I close the double quote. However, the output for script2 ends up a error message:
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""
Nowhere could I find an explanation why there needs to be a space between numbers and . in script2, while no space is needed between numbers and , I am currently relying on google and the free perl books to help me pick up the language. Any help (general guidelines for this kind of nuances) will be greatly appreciated. Thank you.
7.
is a number for perl
lexer, like 3.1415926535
. To avoid confusion, separate the dot from the preceding digit with a space: "the answer is " . 4*7 . " times more complicated"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With