Tinkering with Perl

(Search & Sitemap) > Writing > Miscellaneous Nonfiction > Tinkering with Perl
Skip Back  Previous  48  49  50  51  52  53  54  55  56  57  Next  Skip Forward
Printer-Friendly Version

Syntax errors

If a programming book tells you to write something a certain way, you should do exactly what you're told. If you're told to write:

@a=(1,2);
foreach $b (@a)
    {
	print $b;
    }

and you write:

@a=(1,2);
foreach b (@a)
    {
	print $b;
    }

What will happen?

Something different, and not what you want.

One dollar sign is missing, so the computer will do something different, and not what you want.

Can't the computer just do what you mean?

No. Knowing what you mean shows human intelligence, and the computer can't do it.

What happens quite often is that you write something a little different than what you thought--something a person wouldn't notice--but the computer can't correct. If you're having trouble, read your code closely to see that you typed exactly what you thought you typed.

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  48  49  50  51  52  53  54  55  56  57  Next  Skip Forward
Printer-Friendly Version