Tinkering with Perl

(Search & Sitemap) > Writing > Miscellaneous Nonfiction > Tinkering with Perl
Skip Back  Previous  21  22  23  24  25  26  27  28  29  30  Next  Skip Forward
Printer-Friendly Version

Statements

Let's say that you are going to play at a friend's house. What you might do, could be explained as a list of activities:

Ask your parents for permission to visit your friend.
Call your friend's house, and ask permission to come over.
Finish getting dressed.
Walk over to your friend's house.
Take chewing gumm off of your shoe.
Greet your friend.
Play with your friend.
Eat a snack.
Play some more.
Say goodbye.
Walk home.
Take off your shoes.

What we have done here, is to break one bigger activity (visiting your activity) into a sequence of smaller activities. Another way of putting it is that we are explaining how to visit your friend by saying what smaller things are necessary to visit your friend.

When you are programming a computer, you do the same thing. The little commands are called statements. A statement is a command that tells a computer to do something small, as a part of doing something larger. (Saying to walk to your friend's house, when you are explaining how to visit your friend, is like a statement.)

As we work further, we will learn more about different kinds of statements. But first, let's make sure that we understand what a statement is: a statement is an individual command you give to the computer, as part of telling it how to do something. In the description of how to visit a friend's house, each line, like "Greet your friend," or "Remove chewing gum from your shoe," is like a statement. The whole list, all together, is like a program.

One final note about statements: In English, you usually end a sentence with a period ('.'). In Perl and many other computer languages, you end most statements with a semicolon (';'). For example:

This sentence ends like a statement;

See also:

Assignment of variables - Input and output - Blocks - If-then - Loops - Subroutines

Tinkering with Perl is a free book that provides an introduction to programming in Perl, as well as a basic reference for things like foreach in Perl, if-then, and if-then-else, in addition to providing a glossary where you can find definitions for concatenate and other terms.

Tinkering with Perl may be one of the most popular offerings on this site, but it's not the only attraction. You can read a tongue-in-cheek Game Review: Meatspace, read an even more offbeat customer service survey (whether or not you actually fill it out), and spend a few minutes wishing your boss would read, The Administrator Who Cried, "Important!" (Not to mention that there are other things you can read here besides tech stuff, from Janra Ball: The Headache to The Spectacles.)

Read more...

Top

(Search & Sitemap) > Writing > Miscellaneous Nonfiction > Tinkering with Perl
Skip Back  Previous  21  22  23  24  25  26  27  28  29  30  Next  Skip Forward
Printer-Friendly Version