Perl Functions for List Data

The Perl list 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.

You can manipulate lists through several built-in functions, including:

grep is used as a filter to extract those elements of a list for which an expression (or a regular expression) is evaluated true; it returns the sublist of the elements that passed the filter test
join with this function you can merge any number of strings you want; you can specify with what token you want to delimitate the strings; in other words you can concatenate all the string elements of a list into a string, using a separator
map takes a list and evaluates an expression or block on each element of the list; it returns a list with the results
qw/STRING/ this 'quote word' function is used to generate a list of words and returns the list containing the words; it automatically quotes the strings for you
reverse in a scalar context, it concatenates the elements of a list in a string and returns the string with all the characters in an opposite order; in a list context, it returns the list in the reversed order
sort sorts a list in a specific order and returns the sorted list
unpack it expands a binary string into a list of values by using a template format