Perl List Functions
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 Perl list 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 |
Follow the above links to learn more about how to use the Perl list functions.
Table of Contents:
A Perl Script Install Perl Running Perl Perl Data Types Perl Variables Perl Operators Perl Lists Perl Arrays Array Size Array Length Perl Hashes Perl Statements Perl if Perl unless Perl switch Perl while Perl do-while Perl until Perl do-until Perl for Perl foreach Built-in Perl Functions Functions by Category String Functions Regular Expressions and Pattern Matching List Functions (more) Array Functions Hash Functions Miscellaneous Functions Functions in alphabetical order chomp chop chr crypt defined delete each exists grep hex index join keys lc lcfirst length map oct ord pack pop push q qq qw reverse rindex scalar shift sort splice split sprintf substr tr uc ucfirst undef unpack unshift values
return from Perl List Functions to Perl Basics
Would you like to create your own website like this one? Hit the Alarm Clock!
|