Re-use code with Perl's anonymous functions
An anonymous function in Perl is an unnamed subroutine. But what are they good for? This article shows how through using anonymous functions it’s possible to write more generic, re-usable Perl code.
An anonymous function in Perl is an unnamed subroutine. But what are they good for? This article shows how through using anonymous functions it’s possible to write more generic, re-usable Perl code.
Perl subroutines do not have signatures so variables must be initialized and arguments assigned to them inside the subroutine code. This article describes two useful shortcuts that can simplify this process.
Hashes are one of Perl’s core data types. This article describes the main functions and syntax rules for for working with hashes in Perl.
If you need to write object oriented Perl code with no dependencies, then you need to use the old school Perl syntax. This article describes the main features of old school object oriented Perl including class declaration, constructors, destructors, methods, attributes, accessors and inheritance.
Perl is remarkably flexible and allows you to achieve all kinds of wizardry with the language. One example of this is using a dereferencing block to use a scalar value as a variable name. This allows you to use variables with dynamic names.
Another cool way to get the version of a module
One way to reduce the verbosity of Perl code is to replace if-else statements with a conditional operator expression. The conditional operator (aka ternary operator) takes the form: logical test ? value if true : value if false.
Perl’s for loops are a powerful feature that, like the rest of Perl can be as concise, flexible and versatile required. This article covers the core features for Perl’s for loops.
When Perl is executing a program, it maintains the user id of the process owner in a global variable ($<). When a Perl program is executed by root or a user with root privileges (e.g. using the sudo command), the user id variable is always set to zero. This can be checked at the command line:
A popular way to build a list of literal quotes in Perl is to use the quote whitespace operator (qw). It’s terse, versatile and elegant. To see why, let’s look at a typical statement using a list of strings:
A quick way to list all non-core modules installed via CPAN using the command line:
Although not precisely defined, Modern Perl programming refers to the use of best practice coding syntax, environment configuration tools, new Perl modules and the general joie de vivre associated with Perl since version 5.10.2. During this time the Perl language and available modules went through an upgrade of several tons of awesome, which resulted in a more concise, idiomatic syntax, and powerful new tools including web frameworks, ORMs and configuration managers.