Nuts and Bolts of Perl
Perl is a general-purpose, high-level, interpreted, dynamic programming language. Perl is not an acronym, but some people refer to it as “Practical Extraction and Reporting Language”, was originally developed by Larry Wall as a general-purpose Unix scripting language.
Perl 5 is a feature-rich, highly capable programming language. Perl 5 runs on over 100 platforms from portables to mainframes and is suitable for both rapid prototyping and large scale development projects.
“Perl” is a family of languages, “Perl 6” is part of the family, but it is a separate language which has its own development team. Its existence has no significant impact on the continuing development of “Perl 5”.
PONIE is an acronym for “Perl On New Internal Engine”. The PONIE Project existed from 2003 until 2006 and was to be a bridge between Perl 5 and Perl 6. It was an effort to rewrite the Perl 5 interpreter to run on Parrot, the Perl 6 virtual machine. The PONIE project ended in 2006 and is no longer being actively developed.
Plenv – perl binary manager
plenv is used to pick a Perl version for our application. plenv along with Carton is used for painless Perl upgrades and bulletproof deployments.
- Plenv vs .perlbrew
Like perlbrew, plenv installs perl under our home directory and lets us install modules locally, and allows to switch to arbitrary perl versions on our shell. Unlike perlbrew, plenv is implemented in bash, and provides simple shell script wrappers (called “shims”) for each perl executable files
What is CPAN?
The Comprehensive Perl Archive Network (CPAN) is a repository where all the interesting Perl extension (libraries, modules) live. It’s an automated software installer (somewhat like a package manager). Most software on CPAN is free and open source software. It is based on the (“Comprehensive TeX Archive Network”) CTAN model.
Like many programming languages, Perl has mechanisms to use external libraries of code, making one file contain common routines used by several programs. Perl calls these modules.
The CPAN’s main purpose is to help programmers locate modules and programs not included in the Perl standard distribution. Its structure is decentralized. CPAN is also used to distribute new versions of Perl, as well as related projects, such as Parrot.
Carton – Perl module dependency manager (aka Bundler for Perl)
Carton does a couple of things. It keeps track of the dependencies of a project and their version numbers, given a list of dependencies, and lets you install those specific dependencies on any machine which has carton.
carton is a command line tool to track the Perl module dependencies for our Perl application. Dependencies are declared using ‘cpanfile’ format, and the managed dependencies are tracked in a ‘cpanfile.snapshot’ file, which is meant to be version controlled, and the snapshot file allows other developers of our application will have the exact same versions of the modules.
With this file in place, run carton install. This will install those modules.
Also, Carton requires you to run your command/application with carton exec command, which means it’s difficult or impossible to run in an embedded perl use case such as mod_perl.
What is Mojolicious?
Back in the early days of the web, many people learned Perl because of a wonderful Perl library called CGI, while most of the techniques used are outdated now. Mojolicious is a real-time web application framework, written by Sebastian Riedel, creator of the web application framework Catalyst. It is written in the Perl programming language, and can be installed directly from CPAN.
Some of other perl frameworks are,
- Gantry, etc.
Commonly used Modules:
DBIx::Class – Extensible and flexible object <-> relational mapper
DBIx::Class (abbreviated as DBIC) is an object-relational mapper for Perl. It is used to map relational database table rows to Perl objects and generates SQL queries transparently to the application developer. It also implements the active record pattern. It is popular in Web application frameworks such as Catalyst and Mojolicious.
Minion – Job queue
Minion is a high performance job queue for the Perl programming language, with support for multiple named queues, priorities, delayed jobs, job progress, parallel processing, remote control, Mojolicious admin ui, resource leak protection and multiple backends (such as PostgreSQL).
Carp – alternative warn and die for modules
The Carp routines are useful in your own modules because they act like die() or warn(), but with a message which is more likely to be useful to a user of your module.
CHI – Unified cache handling interface
CHI provides a unified caching API, designed to assist a developer in persisting data for a specified period of time.
Interesting facts about Perl
- Perl was originally named as “Pearl”. Larry Wall wanted to provide a concise and favorable connotation to it and thus shortened it to Perl inside of Pearl.
- Programming Perl features the image of a camel on the cover, which was published by O’ Reilly Media. This image of a camel has become an unofficial symbol of Perl.
- An alternative symbol is also used by Perl Foundation. The symbol is of an onion that the company uses.
- Perl has only 3 data types which simplifies a lot of things. The Scalars ($) – which are flat data (integers, float, string, etc.), the Arrays (@) – which combined data together and the Hashes (%) – which regroups one to one correspondence between data without any specific order.
- The Perl language is referred to as a proper noun and the first letter is capitalized.
- The Perl program is denoted by un-capitalized letter since the unix programs are case sensitive.
- There are two slogans for Perl. One of them is “Easy things are easy and hard things should be possible.” The next one is TIMTOWTDI, pronounced “Tim Toady”, which means ‘There is more than one way to do it.”