Perl Functions by Category

These sites are FOR SALE: miscperlinfo.com, mpihowto.com!
If you are interested, please use my Contact page.




I described on my site some of the most important buit-in functions. They are presented here grouped by categories. Stay tuned for more.


Click Below to See the Best

Perl How-to Snippet Collection

and Save Hours of Surfing on Internet!


Functions for SCALARs or Strings


chomp removes trailing newlines and returns the number of characters removed
chop removes and returns the last character from a string
chr converts ASCII or Unicode values into their corresponding characters
crypt allows you to store passwords or other sensitive data using ASCII characters as encrypted strings
hex converts a hex string into the numerical corresponding value
index returns the position of the first occurrence of a substring in a string
lc converts all the characters of a string in lowercase and returns the new string
lcfirst converts the first character of a string in lowercase and returns the new string
length returns the number of bytes/characters in a string
oct converts an octal string into the numerical corresponding value
ord converts a character into its ASCII/Unicode corresponding value
pack converts a list into a string, according to a user-defined template (ex. a binary representation of a list)
q/STRING/ singly quote a string
qq/STRING/ doubly quote a string
reverse in scalar context, concatenates the elements of a list and returns a string value with all characters in the opposite order
rindex is similar to index, but returns the position of the last occurrence of a substring in a string
sprintf emulates the C sprintf function
substr extracts a substring from a string and returns it
tr/// transliterate a string
uc converts all the characters of a string in uppercases and returns the new string
ucfirst converts the first character of a string in uppercase and returns the new string


Regular Expressions and Pattern Matching

split converts a string into a list and returns that list; the words of the string must be delimitated by a separator


Functions for Real @ARRAYs

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


Functions for List Data

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


Functions for Real %HASHes

delete removes a key-value pair from a hash; you can delete an individual element of a hash or a hash slice.
each returns a two-element list that contains a (key, value) pair from a hash or a (index, value) pair from an array
exists it checks whether a particular hash/array element or a subroutine exists
keys use this function to get the indices of an array or the keys of a hash
values use this function to get the values of an array or a hash


Miscellaneous Functions

defined it tests whether a value, variable or function is defined; using it on an entire array reports if the array has ever been allocated
scalar enables you to evaluate an expression in a scalar context and returns the value of that expression
undef it removes a variable or function definition; if you use it for an entire array, this function will clear the array and free up the system memory allocated for it


A-N-Y-O-N-E Can Learn and Master Perl!
And That Includes YOU!


Check these how-to tutorial eBooks (PDF format):


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 (more)
        String Functions
        List Functions
        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 to Perl Basics



Would you like to create your own website like this one?
Hit the Alarm Clock!

Site Build It!