Perl Tutorial by Code Examples


What is Perl?

Perl is a script language which is good at text processing. Number and string are automatically converted. Powerful regular expression is embedded into Perl language. Performance is higher than other script language such as Ruby. Perl is maybe best choice for the purpose of text processing. you can process a million line containing text file in a practical time although depending on machine performance.

Perl has some better points compared with other script languages in usability and stability . Perl is usually installed in Unix-like or Linux-like OS by default. And Perl installation into Windows is not difficult. There is only one implementation of Perl in this world in positive or negative meaning. you don't suffer from bugs between multiple implementations or versions. Perl is suitable for business use which need long time stability, because Perl have the policy to keep backward compatibility strongly.

Please see ActivePerl installation about Perl installation into Windows.

Perl is script language. You don't have to compile program manually such as Java or C language. You can immediately execute the script. This is a big advantage of script language because program is rewritten many times.

Perl is one of modern programming languages. You can do a lot of things by modules. Some people say that they use Perl for CPAN, which have a lot of libraries whoever use freely. Perl is old language, but development of Perl modules is very active, because Perl have good module packaging and testing system to make it easy.

Perl is one of languages which can write clean source code. Perl is old language. Perl seem to have a little older writing style, but Perl can write clean source code in the view of creating good program structure. If you are familiar with Perl, you can write source code by natural feeling.

Perl features

  1. Perl is good at text processing. The performance is fast.
  2. Installation is easy. Backward compatibility is kept strongly.
  3. Don't need compile. you can execute program immediately
  4. You can do modern powerful programming
  5. You can write clean program structure

I recommend Perl for the following people

  1. People who want to automate daily works.
  2. People who learned static language such as Java , C , C++ , C#, then want to learn dynamic language.
  3. People who learned Excel VBA, then want to learn another useful language.
  4. People who develop iPhone application by Objective-C, then want to create Web(HTML5) application.
  5. People who learned PHP for web application, then want to learn general purpose programming language.
  6. People who think text processing by bash or csh are difficult.
  7. People who think the limit of text processing by awk or sed.
  8. People who have troubles with Python2 and Python3 incompatibility.
  9. People who use ruby and want more performance and stability.
  10. People who learn javascript such as node.js, then want more useful script language.

Perl is a script language similar to Python or Ruby. In three languages, there are little difference in programming ability. Perl features are "Easy to use", "Less memory", "Use in many environments by default", "Stability of implementation ", "Performance of text processing". Perl syntax is similar to C language, Java, PHP, JavaScript. you can learn Perl easily. If you use Perl, you will notice Perl is good balanced language in performance, features, and syntax. Let's try Perl.

Big advantage of Perl compared with Python and Ruby is Perl keep backward compatibility strongly, so you can use Perl safely in job. See also Perl is a backward compatibility keeping language.

Perl text processing is about 2〜3 times faster than Ruby. And Perl require less memory. (Compare Perl 5.12.2 with Ruby 1.9.1 in text processing in Windows, Comparison in Benchmark Game site)

Same as PHP and Javascript, Perl is useful to create web application . You can use useful modules on CPAN. The modules will make efficiency of web development very high.

If you develop iPhone application with Objective C, you maybe think "I want to try HTML5 application". In such case, Perl is useful. (Web Application description)

See also Perl FAQ.

About "Perl Tutorial by Code Examples"

This site is Perl tutorial, introduce many code examples. I aim to write Perl document which have less mistake, and useful. "Perl Tutorial by Code Examples" have some features other sites don't have.

1. Modern Perl writing style

Source codes of this site are written by modern Perl writing style, although many old other sites have Perl4 writing style. This site don't have Perl4 writing style. If you learn Perl from now, try modern Perl writing style. If you see this site code example and write source code, you will master modern Perl writing style quickly.

I recommend to read next two contents at the beginning. You can learn Perl basic syntax and modern writing style.

2. Many examples

Many of this site contents have simple code example and simple description. Detailed descriptions is useful for the people who want to understand Perl internal, but not useful for the people who want to use Perl practically. I prepare many simple examples and simple descriptions for peoples who use Perl practically.

3. Useful information

This site aim to collect useful information. After you learn basic syntax, it is good to learn standard functions and standard modules to master Perl quickly. This site have many descriptions about usage of regular expression, standard functions, standard modules.

The features of "Perl tutorial by code examples"

  1. Modern Perl writing style
  2. Many examples
  3. Many descriptions about usage of regular expression, standard functions, standard modules

Know the following things when you read "Perl Tutorial by Code Examples"

In modern Perl, You should write the following two lines at the start of script.

use strict;
use warnings;

In this site examples, this two lines is sometime omitted. I omit two lines when I think it is understandable to omit two lines for description. But if you write source code by yourself, you should write strict and warnings lines.

About Perl6

Perl6 is being developed as different project from Perl5. Some people think Perl6 is evolved language of Perl5. but Now Perl6 is not evolved language Perl5. Perl6 is not Perl5 successor. Perl6 is different language of Perl5. Perl6 is yet uncompleted language.

Perl5 development is active because there are many people who hope Perl5 continual development. Perl5 is most safely language of all script languages because Perl is developed in the policy that Perl take care of past scripts and modules.


I'm happy if you learn Perl, enjoy Perl, and make your works easy by Perl. Please inform "Perl Tutorial by Code Examples" for the people who want to learn Perl quickly or want to see Perl many examples.

Table of contents



トラックバック - http://d.hatena.ne.jp/perlcodesampleen/20100228/1269445781