27 April 2011

การใช้ quote ใน perl

double qoute (") ค่าที่อยู่ใน doble qoute ถ้าเป็นตัวแปรจะแสดงค่าของตัวแปรนั้นออกมา ถ้าเป็นตัวอักษรพิเศษก็จะแสดงตัวอักษรพิเศษออกมา

single qoute (') ค่าที่อยู่ใน single qoute จะแสดงตามที่อยู่ข้างในทั้งหมด

black qoute (`) ค่าที่อยู่ในนี้คือคำสั่ง shell หรือ dos โดยจะ return ค่าผลลัพธ์ที่ได้ สามารถใช้ตัวแปรมารับค่าได้

#!c:\perl\bin\perl
print "content-type:text/html \n\n";
print "Hello World\n"; #จะได้ Hello World
print 'Hello World\n'; #จะได้ Hello World\n
print `date`; #จะได้ The current date is: Wed 04/27/2011 Enter the new date: (mm-dd-yy)

ผลลัพธ์ใน browser
Hello World Hello World\nThe current date is: Wed 04/27/2011 Enter the new date: (mm-dd-yy)

ผลลัพธ์ใน view->source
Hello World
Hello World\nThe current date is: Wed 04/27/2011
Enter the new date: (mm-dd-yy)

0 comments:

Post a Comment