How to concatenate variables in Perl

后端 未结 6 1128
面向向阳花
面向向阳花 2020-12-18 01:37

Is there a different way to concatenate variables in Perl?

I accidentally wrote the following line of code:

print \"$linenumber is: \\n\" . $linenumb         


        
6条回答
  •  伪装坚强ぢ
    2020-12-18 02:21

    You can backslash the $ to print it literally:

    print "\$linenumber is: \n" . $linenumber;
    

    That prints what you were expecting. You can also use single quotes if you don't want Perl to interpolate variable names, but then the "\n" will be interpolated literally.

提交回复
热议问题