Last Updated:

Alphabet of the language | PERL

Starting to get acquainted with any programming language, we first of all find out what types of data it allows you to process, whether the language provides a mechanism for creating new types from existing ones. After all, the programming language, as a sign information processing system, is precisely designed to process information represented by data and algorithms. Data is defined by its type— a set of values and a set of valid operations.

Some programming languages offer a large number of different data types, such as the universal C language, in which even the data type used to store characters can be signed or unsigned; others can get by with only two types of data, such as VBScript, which uses a single variant data type to store and process any scalar data (numeric, string, and Boolean) and has the ability to create scalar data arrays. Ultimately, the language must have such a variety of data types that the programmer can use them to solve the problems for which the programming language is intended.

The Perl language offers only three types of data to solve its problems: scalars, scalar arrays, and associative scalar arrays, or hashes. According to the valid data types, there are also three types of variables in which you can store data of the listed types. This chapter defines all the data types allowed in the language, introduces numeric and string literals, array constructors and associative arrays, and discusses variables and their use, but we will begin our study with the question without which it is impossible to enter into any programming language - a set of valid characters, or the alphabet of the language.

How does learning any language start? Of course, from the alphabet. Remember how in the first grade we diligently displayed in words all the letters of the Russian alphabet, and in high school, starting to study a foreign language, we first learned the letters of its alphabet and what sounds they denoted, and then from the letters we put together words that could already be used to make sentences that carry a certain informativeness: "Mom washed the frame."

A similar thing happens when learning programming languages. First we have to figure out which characters can be used to compose lexemes (language words) from which operators (language sentences) can be constructed.

In Perl, you can use all latin letters (uppercase and lowercase), Arabic numerals, and the underscore "_". Perl refers to case-sensitive languages. This means that the uppercase and lowercase characters are considered different. Therefore, for example, the two identifiers one and one used to name a variable are two different identifiers, and therefore the variables of the same type they define are also different.

Note
Letters of national alphabets, in particular Russian, can only be used in string data. Variable identifiers can contain letters of only the Latin alphabet. In addition to letters, numbers, and underscores, which are called alphanumeric characters, the set of special characters presented in Table 3.1 is used.

Table 3.1. Perl special characters.

SymbolNameSymbolName
`Reverse apostrophe~Tilde
!Exclamation point@Commercial AT
Number$Dollar sign
%Percent^"Lid"
&Ampersand*Asterisk
 Minus+Plus
=Equality|Vertical bar
'Direct apostrophe"Quotation marks
<Less>More
/Slash\Backslash
,Comma.Dot
:Colon;Semicolon
[Square left bracket]Right square bracket
{Curly left bracket}Right curly brace
(Left bracket)Right parenthesis
?Question mark Gap

Analysis of special characters shows that Perl uses all characters that can be entered from the keyboard. If alphanumeric characters are used as part of identifiers, special characters are used to identify the signs of operations, clarify the syntax of expressions, and name special built-in Perl variables. If any of the listed objects are not entirely clear to the reader now, then with the subsequent presentation everything will fall into place. The alphabet of a language is used to create "correct" (recognized by the language interpreter) lexemes. Among the many such tokens, there is a subset of predefined tokens called keywords used to create the correct language constructs.

The set of Keywords of the Perl language is not large and is presented below:

if, elseif, else, unless, while, until, foreach, for, next,
 continue, last, do, eval, goto, sub, my, return

In addition to the listed keywords that define syntactic language constructs, the Perl language has a set of standard functions that are implemented in any perl interpreter. The names of these functions can also be considered reserved words of the language and not used as user-defined function names or labels in the program. We will not list the names of all the standard functions here, since their number is quite large, and there will be little benefit from such a simple enumeration, but we will send the reader to Appendix A, where he can see the names of all the standard functions.