วันจันทร์ที่ 5 มกราคม พ.ศ. 2558

การเขียนโปรแกรมภาษา Perl บนระบบปฏิบัติการ Debian 7.7 GNU/Linux


       Perl เป็นภาษาสคริปต์ที่ทำงานโต้ตอบกับผู้เขียน และผู้ใช้โปรแกรม สามารถประมวลผล
โดยการคำนวณ เปรียบเทียบจัดเรียง การประมวลผลภาพและเสียง เป็นต้น  ภาษา Perl ส่วนใหญ่
จะติดตั้งมาบนค่าเริ่มต้นบนระบบปฏิบัติการลินุกซ์ หรือระบบปฏิบัติการคล้าย Unix อื่น ๆ
ภาษา Perl เป็นอีกภาษาหนึ่งที่ใช้งานง่าย เขียนโปรแกรมเสร็จเพียงกำหนดสิทธิ์ของไฟล์หรือ
โปรแกรมที่เขียนให้สามารถอ่าน และเขียนข้อมูลได้ก็จะสามารถใช้งาน (Run) โปรแกรมได้ทันที
        ภาษา Perl ยังมีข้อดีคือสามารถเป็นสื่อกลางระหว่าง Servers ทำหน้าที่รับส่งข้อมูล
ประมวลผลระหว่าง Sevres ได้เป็นอย่างดี เช่น เป็นตัวกลางระหว่าง Web server กับ Database
server หรือ Mail severver ได้  นอกจากนี้ภาษา Perl ยังใช้งานเดี่ยว ๆ เพื่อศึกษาการใช้งาน รูปแบบ
คำสั่งได้อย่างมีประสิทธิภาพอีกด้วย


submarine@Debian77:~$ which perl
/usr/bin/perl
submarine@Debian77:~$ perl --version

This is perl 5, version 14, subversion 2 (v5.14.2) built for i486-linux-gnu-thread-multi-64int
(with 89 registered patches, see perl -V for more detail)

Copyright 1987-2011, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

submarine@Debian77:~$
submarine@Debian77:~$ mkdir Perl
submarine@Debian77:~$ cd Perl/
submarine@Debian77:~/Perl$
submarine@Debian77:~/Perl$ pico test.pl
submarine@Debian77:~/Perl$ chmod +x test.pl
submarine@Debian77:~/Perl$ ls -l
total 4
-rwxr-xr-x 1 submarine submarine 46 Jan  5 16:59 test.pl
submarine@Debian77:~/Perl$
submarine@Debian77:~/Perl$ ./test.pl
Perl Programming
submarine@Debian77:~/Perl$

submarine@Debian77:~/Perl$ pico thai.pl

#!/usr/bin/perl
print "ทดสอบการใช้ภาษาไทย โดยใช้ภาษา Perl บน Debian 7.7 GNU/Linux\n";

submarine@Debian77:~/Perl$ chmod +x thai.pl

submarine@Debian77:~/Perl$ ./thai.pl
ทดสอบการใช้ภาษาไทย โดยใช้ภาษา Perl บน Debian 7.7 GNU/Linux
submarine@Debian77:~/Perl$


submarine@Debian77:~/Perl$ pico while_loop.pl
submarine@Debian77:~/Perl$

#!/usr/bin/perl
#

$while_loop=5;

# Definition of perl while loop
while ($while_loop>=0) {
       print "while loop value is:".$while_loop."\n";
       $while_loop--;
       } 

submarine@Debian77:~/Perl$
submarine@Debian77:~/Perl$ chmod +x while_loop.pl
submarine@Debian77:~/Perl$ ./while_loop.pl
while loop value is:5
while loop value is:4
while loop value is:3
while loop value is:2
while loop value is:1
while loop value is:0
submarine@Debian77:~/Perl$



ไม่มีความคิดเห็น:

แสดงความคิดเห็น