Perl Array Functions
The Perl array functions are one of the most important category of the built-in Perl functions. As you know, three data types are available in the Perl language: scalars, arrays and hashes.
A scalar, which represents the fundamental type of Perl data, can be a string, a number or a reference. When you group together two or more scalars, you have a list.
If you want to refer a list throughout a Perl script, you need an array variable, represented in Perl by an identifier preceded by the @ symbol.
If some of the elements of an array are references to other arrays or structures, we say that we have a multidimensional array.
The Perl language supplies a lot of functions to manipulate arrays. Every time you call a Perl array function, you must distinguish between a simple array and a multidimensional one.
For instance, if you have an array which has as elements references to other arrays or hashes and if you want to delete all its elements, you need to step down through all its sub-arrays and delete their elements too.
Follow the below links to see how to use the Perl array functions.
|pop||removes and returns the last element of an array; the size of the array decreases by 1|
|push||appends the elements of a list to an array; the size of the array increases by the size of the list|
|shift||removes and returns the first element of an array, reducing the number of the array elements by one|
|splice||removes a subarray from an array and eventually replaces it with another array|
|unshift||inserts a value or a list of values at the beginning of an array and returns the new total number of the array’s elements|
Table of Contents:
A Perl Script
Perl Data Types
Built-in Perl Functions
Functions by Category
Regular Expressions and Pattern Matching
Array Functions (more)
Functions in alphabetical order
return from Perl Array Functions to Perl Basics
Would you like to create your own website like this one?
Hit the Alarm Clock!