Perl arrays 101 - create, loop and manipulate
Arrays in Perl contain an ordered list of values that can be accessed using built-in functions. They are one of the most useful data structures and frequently used in Perl programming.
Arrays in Perl contain an ordered list of values that can be accessed using built-in functions. They are one of the most useful data structures and frequently used in Perl programming.
A typical way to print every element of an array in Perl is using a foreach loop:
You get the idea - Perl has a repetition operator (x) that repeats the scalar or list on its left by the number on it’s right (like multiplication).
Perl ships with a command-line program called perldoc that makes it easier to search and read Perl’s vast documentation in the POD markup language. If perldoc is called with the -F flag, it will display the POD markup of an input file - this can be useful when your are developing a new Perl distribution and want to check the appearance of the POD in your module before it appears on CPAN for all to see.
Perl has many string functions, let’s take a look at a some of the most common ones: concatenate, substring and split.
Broadly speaking Perl has two types of strings: quotes that are interpolated at runtime and literal quotes that are not interpolated. Let’s review each of these in turn.
Most Perl programmers know that to find the size of an array, the array must called in a scalar context like this:
Perl module features and behaviour can change from version to version and so knowing the version number of an installed Perl module can be useful in several scenarios. Below are three different command line methods for finding out the version number of an installed module that work on Bash and Windows Powershell. So fire up the terminal and get typing!
Many practical programming problems require you to parse data. Ron Savage continues his demonstration of Marpa and other tools and techniques for lexing and parsing data. Put down the regexps; get it right this time.
When JT Smith ported his web game The Lacuna Expanse to a board game, he used Perl to create the board game itself. Here’s how he built the web service behind The Game Crafter.
When JT Smith ported his web game The Lacuna Expanse to a board game, he used Perl to automate things. Here’s how he did it.
Kevin Carillo asks for assistance surveying newcomers to the Perl community about their experiences, positive and otherwise.
Perl programmers spend a lot of time reading, modifying, and writing data. When regular expressions aren’t enough, turn to something more powerful: parsing.
Thanks to Torsten Raudssus, who wrote in with this announcement. What is Plat_Forms? Plat_Forms is a contest and competition in which top-class teams of three programmers compete to implement the same requirements for a web-based system within two days, using…
editor’s note: an earlier version of this article appeared at The Reluctant Perl Programmer. Per the suggestion of Ask Bjørn Hansen, this revision appears on Perl.com. Who We Are We all love Perl for different reasons. Some of us are…
This series has shown you several features of Unicode by example, as well as several techniques for working with Unicode correctly and easily with recent releases of Perl 5. By now you know more than many programmers do about Unicode,…
℞ 44: PROGRAM: Demo of Unicode collation and printing The past several weeks of Unicode recipes have explained how Unicode works and shown how to use it in your programs. If you’ve gone through those recipes, you now understand more…