For faster navigation, this Iframe is preloading the Wikiwand page for ภาษาเพิร์ล.

ภาษาเพิร์ล

ภาษาเพิร์ล
กระบวนทัศน์กระบวนทัศน์การเขียนโปรแกรม: เชิงฟังก์ชัน, เชิงคำสั่ง, เชิงวัตถุ (class-based), reflective
ผู้ออกแบบแลร์รี วอลล์
ผู้พัฒนาแลร์รี วอลล์
เริ่มเมื่อ18 ธันวาคม 1987; 36 ปีก่อน (1987-12-18)
รุ่นเสถียร
  • 5.30.1[1] / 10 พฤศจิกายน 2019; 4 ปีก่อน (2019-11-10)
  • 5.28.2[2] / 19 เมษายน 2019; 5 ปีก่อน (2019-04-19)
รุ่นทดลอง
5.31.6[3] / 20 พฤศจิกายน 2019; 4 ปีก่อน (2019-11-20)
ระบบชนิดตัวแปรDynamic
ภาษาโปรแกรมC
ระบบปฏิบัติการCross-platform
สัญญาอนุญาตArtistic License 1.0[4][5] or GNU General Public License[6]
นามสกุลของไฟล์.pl, .pm, .xs, .t, .pod
เว็บไซต์www.perl.org
ได้รับอิทธิพลจาก
AWK, BASIC, C, C++, Lisp, sed, Unix shell[7]
ส่งอิทธิพลต่อ
CoffeeScript,[ต้องการอ้างอิง] Groovy,[ต้องการอ้างอิง] JavaScript, Julia, LPC, PHP, Python, Raku, Ruby, Windows PowerShell

ภาษาเพิร์ล (อังกฤษ: Perl) (ย่อมาจาก Practical Extraction and Report Language) เป็นภาษาโปรแกรมแบบไดนามิก พัฒนาโดยนายแลร์รี วอลล์ (Larry Wall) ในปี ค.ศ. 1987 เพื่อใช้งานกับระบบปฏิบัติการยูนิกซ์

ภาษาเพิร์ล นั้นถูกออกแบบมาให้ใช้งานได้ง่าย โครงสร้างของภาษาจึงไม่ซับซ้อน มีลักษณะคล้ายกับภาษาซี นอกจากนี้เพิร์ลยังได้แนวคิดบางอย่างมาจากเชลล์สคริปต์, ภาษา AWK, sed และ Lisp

ปัจจุบันเวอร์ชันล่าสุดคือ 5.18.0

โครงสร้างของภาษา

[แก้]

ตัวอย่างการเขียนโปรแกรม Hello World ด้วยภาษาเพิร์ล

#!/usr/bin/perl
print "Hello, world!\n";    # '\n' is a 'newline'

บรรทัดแรกเป็นการประกาศให้ระบบปฏิบัติการค้นหาตัวแปลภาษาเพิร์ลตามตำแหน่งที่ระบุ ส่วนบรรทัดที่สองเป็นการพิมพ์ข้อความ (หรือสตริง) ว่า "Hello, world!" และสัญลักษณ์ในการขึ้นบรรทัดใหม่ออกมา ตามด้วยความเห็นหรือคอมเมนต์ว่า '\n' is a 'newline' ในบรรทัดเดียวกัน สำหรับรุ่น 5.10 สามารถเขียนได้อีกแบบว่า

#!/usr/bin/perl
say "Hello, world!";

ตัวแปร

[แก้]

ภาษาเพิร์ลมีตัวแปรอยู่ 4 ชนิด ได้แก่

  • สเกลาร์ สามารถเก็บข้อมูลได้ 1 อย่าง อาจจะเป็น ตัวเลข, สตริง หรือ รีเฟอเรนซ์ ก็ได้
  • อาเรย์ เป็นเสมือนกลุ่มของสเกลาร์ที่ถูกเรียงไว้
  • แฮช หรืออีกชื่อหนึ่งคือแถวลำดับแบบจับคู่ เป็นเสมือนตู้ล็อกเกอร์สำหรับเก็บสเกลาร์ กุญแจที่จะใช้ไขตู้ล็อกเกอร์จะเรียกว่า keys
  • ไฟล์แฮนเดิล เป็นตัวแปรที่ใช้สำหรับ I/O โดยเฉพาะ อาจจะใช้สำหรับรับการสั่งงานจากผู้ใช้ผ่านทาง Standard Input หรือใช้สำหรับแสดงผลออกทาง Standard Output

แหล่งข้อมูลอื่น

[แก้]

อ้างอิง

[แก้]
  1. "Perl 5.30.1 is now available!". www.nntp.perl.org. สืบค้นเมื่อ 2019-11-10.
  2. "Perl 5.28.2 is now available!". www.nntp.perl.org. สืบค้นเมื่อ 2019-04-19.
  3. "Perl 5.31.6 is released". perl.org. สืบค้นเมื่อ 2019-11-21.
  4. "The "Artistic License" - dev.perl.org". dev.perl.org.
  5. Artistic - file on the Perl 5 git repository
  6. "Perl Licensing". dev.perl.org. สืบค้นเมื่อ 2011-01-08.
  7. Larry Wall. "Programming is Hard, Let's Go Scripting..." All language designers have their occasional idiosyncracies. I’m just better at it than most.


{{bottomLinkPreText}} {{bottomLinkText}}
ภาษาเพิร์ล
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?