Friday, February 4, 2011

PERL : Quoting Nuances

touch escape.pl
pico escape.pl
#!/usr/bin/perl -w
$name = "Mark";
print '$Mark\n'
#END
perl -w escape.pl -> prints $Mark\n


#!/usr/bin/perl -w
$name = "Mark";
print '$Mark\n', "$Mark\n"
#END


#!/usr/bin/perl -w
$name = "Mark";
print '$Mark\n';
print "$name\n";
#END
prints $Mark\nMark


#!/usr/bin/perl -w
$name = "Mark";
print '$Mark\n " ';
print "Aren't you glad to see me?";
#END
Prints ->$Mark\n " Aren't you glad to see me?
#\ - Escape character for Perl BASH
print "C:\windows" -> nothing happends
print "C:\\windows" -> C:\windows
print "C:\\Documents and Settings","\n" -> C:\Documents and Settings
print q{'' ""}; -> '' ""
#print qq{'' ""}; -> '' ""
prnt qq(\n$name\n); -> Mark

No comments:

Post a Comment