Monday, March 26, 2007

Script pertama perl

Ini adalah artikel yang pertama dalam blog ini tentang pemrograman, disini akan saya bahas bagaimana menjalankan script perl di mesin linux/unix, yang saya gunakan adalah server linux Debian, yang sudah terinstall perl V 5.8.4.
Sebelum memulai kita cek dulu apakah sistem sudah terinstall perl atau belum, untuk melihatnya gunakan perintah


#perl -v


---> # adalah shell console pada system
jika sudah terinstall akan muncul tampilan sebagai berikut:
---------------------------------------------------------------------------

This is perl, v5.8.4 built for i386-linux-thread-multi

Copyright 1987-2004, 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.com/, the Perl Home Page.

---------------------------------------------------------------------------
anda dapat mendownload perl dari http://www.cpan.org

Untuk memulai script perl, kita harus mengetahui terlebih dahulu letak dari program perl, dengan mengetikan perintah:

#whereis perl
perl: /usr/bin/perl /etc/perl /usr/lib/perl /usr/local/lib/perl /usr/share/perl /usr/share/man/man1/perl.1.gz

dari output di atas berari progran perl berada di /usr/bin/perl

dengan menggunakan editor kesukaan anda buat script perl sebagai berikut:


#!/usr/bin/perl

print "Hello World\n";


simpan script di atas dengan nama hello.pl

Setelah itu ubah mode filenya menjadi file executeable, dengan menggunakan perintah chmod,


#chmod +x hello.pl


atau


#chmod 755 hello.pl


jalankan script diatas :


#./hello.pl
Hello World


Selamat mencoba!!!

3 comments:

  1. Anonymous26/2/12 04:23

    Kalau wxperl gimana tuh

    ReplyDelete
  2. duh gimana ya...
    tp tetep aja biasanya install perl di c:\perl\bin\perl.exe

    dah lama jg udah ga ngoprek perl lagi :)

    ReplyDelete
  3. duh gimana ya...
    tp tetep aja biasanya install perl di c:\perl\bin\perl.exe

    dah lama jg udah ga ngoprek perl lagi :)

    ReplyDelete

Your Comment here