start page | rating of books | rating of authors | reviews | copyrights

Programming Perl

Programming PerlSearch this book
Previous: We'd Like to Hear from You Chapter 1 Next: 1.2 Natural and Artificial Languages
 

1. An Overview of Perl

Contents:
Getting Started
Natural and Artificial Languages
A Grade Example
Filehandles
Operators
Control Structures
Regular Expressions
List Processing
What You Don't Know Won't Hurt You (Much)

1.1 Getting Started

We think that Perl is an easy language to learn and use, and we hope to convince you that we're right. One thing that's easy about Perl is that you don't have to say much before you say what you want to say. In many programming languages, you have to declare the types, variables, and subroutines you are going to use before you can write the first statement of executable code. And for complex problems demanding complex data structures, this is a good idea. But for many simple, everyday problems, you would like a programming language in which you can simply say:

print "Howdy, world!\n";

and expect the program to do just that.

Perl is such a language. In fact, the example is a complete program,[ 1 ] and if you feed it to the Perl interpreter, it will print " Howdy, world! " on your screen.

[1] Or script, or application, or executable, or doohickey. Whatever.

And that's that. You don't have to say much after you say what you want to say, either. Unlike many languages, Perl thinks that falling off the end of your program is just a normal way to exit the program. You certainly may call the exit function explicitly if you wish, just as you may declare some of your variables and subroutines, or even force yourself to declare all your variables and subroutines. But it's your choice. With Perl you're free to do The Right Thing, however you care to define it.

There are many other reasons why Perl is easy to use, but it would be pointless to list them all here, because that's what the rest of the book is for. The devil may be in the details, as they say, but Perl tries to help you out down there in the hot place too. At every level, Perl is about helping you get from here to there with minimum fuss and maximum enjoyment. That's why so many Perl programmers go around with a silly grin on their face.

This chapter is an overview of Perl, so we're not trying to present Perl to the rational side of your brain. Nor are we trying to be complete, or logical. That's what the next chapter is for.[ 2 ] This chapter presents Perl to the other side of your brain, whether you prefer to call it associative, artistic, passionate, or merely spongy. To that end, we'll be presenting various views of Perl that will hopefully give you as clear a picture of Perl as the blind men had of the elephant. Well, okay, maybe we can do better than that. We're dealing with a camel here. Hopefully, at least one of these views of Perl will help get you over the hump.

[2] Vulcans (and like-minded humans) should skip this overview and go straight to Chapter 2, The Gory Details , for maximum information density. If, on the other hand, you're looking for a carefully paced tutorial, you should probably get Randal's nice book, Learning Perl (published by O'Reilly & Associates). But don't throw out this book just yet.


Previous: We'd Like to Hear from You Programming Perl Next: 1.2 Natural and Artificial Languages
We'd Like to Hear from You Book Index 1.2 Natural and Artificial Languages