Äîêóìåíòàöèÿ
HTML CSS PHP PERL äðóãîå

Hour 2. Perl's Building Blocks: Numbers and Strings

 
Previous Table of Contents Next

Hour 2. Perl's Building Blocks: Numbers and Strings

What You'll Learn in This Hour:

Every programming language—and every human language—has a similar beginning: You have to have something to talk about. In Perl, numbers and strings are the basic unit of conversation, and these are called scalars.

Every hour in this book deals in some way with scalars—increasing, decreasing, querying, testing, collecting, clearing, separating, folding, sorting, saving, loading, printing, and deleting them. Scalars are Perl's singular nouns; they can represent a word, a record, a document, a line of text, or a character.

Some scalars in Perl can represent information that does not change over the life of the program. Some programming languages call these values constants or literals. Literal data is used for things that simply do not change, such as the value of p, the rate of acceleration of a body falling to Earth, and the name of the 15th President of the United States. If these values are needed by a Perl program, they would, at some point in the program, be represented by a scalar literal.

The other kinds of scalars in Perl are those that change, called scalar variables. Variables hold data while you manipulate it. You can change the contents of variables because they merely act as handles for the data they represent. Variables are given names—convenient and easy-to-remember names, ideally—that enable you to refer to the data you are manipulating.

This hour also introduces Perl's operators. They are one kind of verb in the Perl language. Operators take Perl's nouns and do the actual manipulations you need to write programs that perform useful tasks.

    Previous Table of Contents Next
    © 2000- NIV