Tuesday, 21 July 2015

Perl : differences between double-quoted strings and single-quoted strings

 : differences between double-quoted strings and single-quoted strings.
# Hello World Program in Perl
#
 = "a string";
$text1 = "This is $string"; # becomes "This is a string"
$text2 = 'This is '; # remains 'This is '
$text3 = 'This string contains \', a quote character';
$text4 = 'This string ends with a backslash \\';

print "$text1 \n";
print "$text2 \n";
print "$text3 \n";
print "$text4 \n";


Result 
This is a string                                                                                                                                                                                    
This is $string                                                                                                                                                                                     
This string contains ', a quote character                                                                                                                                                           
This string ends with a backslash \ 


No comments:

Post a Comment