What's the difference between single and double quotes in Perl?

后端 未结 6 1281
小蘑菇
小蘑菇 2020-11-30 13:50

In Perl, what is the difference between \' and \" ?

For example, I have 2 variables like below:

$var1 = \'\\(\';
$var2 = \"         


        
6条回答
  •  离开以前
    2020-11-30 14:17

    Perl takes the single-quoted strings 'as is' and interpolates the double-quoted strings. Interpolate means, that it substitutes variables with variable values, and also understands escaped characters. So, your "\(" is interpreted as '(', and your regexp becomes m/(/, this is why Perl complains.

提交回复
热议问题