Data Types

Domain Hosting image
Web Hosting
Dedicated server
ssl certificate
Web Design image
Email

Perl uses four types of literals.

Numbers
Strings
Arrays
Associative Arrays

Numeric literals are frequently used. They represent a number that your program will need to work with.

String Literals are groups of characters surrounded by quotes so that they can be used as a single datum. They are frequently used in programs to iden,,filenames, display messages, and prompt for input. In Perl you can use single quotes ('), double quotes("), and back quotes H. Escape sequences represent characters that are not easily entered us, keyboard or that are difficult to see inside an editor window. The Table shows all of the escape sequences that Perl understands.

Escape Sequences - Description or Character

\a - Alarm bell
\b - Backspace
\e - Escape
\f - Form Feed
\n - Newline
\r - Carriage Return
\t - Tab
\v - Vertical Tab
\$ - Dollar Sign
\0nnn - Any Octal byte
\Xnn - Any Hexadecimal byte
\cn - Any Control character
\l - Change the next character to lowercase
\u - Change the next character to uppercase
\L - Change the following characters to lowercase until a \E sequence is encountered. Note that you need to use an uppercase E here, lowercase will not work. Quote meta characters as literals.
\U - Change the following characters to uppercase until a \E sequence is encountered. Note that you need to use an uppercase E here, lowercase will not work.
\E - Terminate the\L, \Q, or\U sequence, Note that you need to use an uppercase E here, lowercase will not work.
\\ - Backslash Array Literals

Perl uses arrays or lists to store a series of items. You could use an array to hold all the lines in a file, to help sort a list of addresses, or to store a variety of items. This is the most complicated data type. Think of it as a list in which every value has an associated lookup item.

Imagine that you have a paper list that has two columns: employee numbers and names. There is exactly one employee for each employee number, and the numbers are not in sequence. For example the list might look like .

ID - Names

742 - Rakesh
1020 - Bajju
1934 - Harrison

Your could make a Perl array that looked like this:
(742, 'Rakesh', 1020, 'Bujji', 1934, Harrison')

But this list does not really embody the same feeling as the paper list because the even numbered items are ID numbers, and odd elements are the names, To search for a particular ID numbers, you have to look at every other item in the list, not every item.

Because these kinds of list are common in many fields, Perl has another kind of list, called an associative array (hash), that acknowledges that you often don't want to find all item by its position.

An associative array is a list of key value pairs. That is, you look it up by its keys. The key value should be unique.

Now you learned about literals, values that don't change while your program runs because you represent them in your source code exactly as they should be used. Most of the time, however, you will need to change the values that your program uses. To do this, you need to set aside pieces of computer memory to hold the changeable values. And, you need to keep track of where all these little areas of memory are, so you can refer to them while your program runs.

Perl, like all other computer languages, uses variables to keep track of the usage of computer memory. Every time you need to store a new piece of information, you assign it to a variable.



Domain Name Search

www.


Copyright (C) 2007. Web Domain design hosting. All rights reserved.