Jonathan's Corner
(Search & Sitemap)
> Writing >
Miscellaneous Nonfiction >
Tinkering with Perl
Skip Back
Previous
40
41
42
43
44
45
46
47
48
49
Next
Skip Forward
Printer-Friendly Version
Some subroutines and functions need information to do their job. For example, you might have a subroutine to tell the price for so many apples, so many oranges, and so many bananas -- but first you need to tell it how many apples, oranges, and bananas there are, so it can calculate them!
That is done by giving the subroutine or function some arguments. The way you use a subroutine/function is to give an ampersand ('&') before the name of the subroutine/function, then its name, and then a list of arguments. For example, if we used the subroutine I mentioned, you might invoke it like this:
&TellPrice($NumberOfApples, $NumberOfOranges, $NumberOfBananas);
We'll see exactly how to write such a subroutine here.
Variables - Scalars - Lists - Flow control - Subroutines and functions - Subroutines - Functions
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.)
Jonathan's Corner
(Search & Sitemap)
> Writing >
Miscellaneous Nonfiction >
Tinkering with Perl
Skip Back
Previous
40
41
42
43
44
45
46
47
48
49
Next
Skip Forward
Printer-Friendly Version