Permalink
Browse files

Edited chapter 1 per Peter Aronoff (GH #23).

  • Loading branch information...
1 parent 9c2e123 commit 934b7d72df449dc7cbaf16a92efed32fccdedb0b @chromatic committed Jul 27, 2010
Showing with 30 additions and 25 deletions.
  1. +3 −0 CREDITS
  2. +15 −17 sections/context_philosophy.pod
  3. +6 −3 sections/expressivity.pod
  4. +6 −5 sections/perldoc.pod
View
@@ -122,3 +122,6 @@ E: asavige@cpan.org
N: Matthias Bloch
E: matthias.bloch@puffin.ch
+
+N: Peter Aronoff
+E: telemachus@arpinum.org
@@ -38,17 +38,19 @@ X<context; amount>
X<amount context>
One of the aspects of context governs I<how many> items you expect. This is
-I<amount context>. Compare this context to compare it to subject-verb number
-agreement in English. If you can spot the error in the sentence "Perl are a
-fun language", you already know how to do this.
+I<amount context>. Compare this context to subject-verb number agreement in
+English. Even if you haven't learned the formal description of the rule, you
+probably understand the error in the sentence "Perl are a fun language". The
+rule in Perl is that the number of items you request determines how many you
+get.
X<void context>
X<context; void>
-Suppose you have a function called C<some_expensive_operation()> which performs
-an expensive calculation and can produce many, many results. If you call the
-function on its own and never use its return value, you've called the function
-in I<void context>:
+Suppose you have a function (L<functions>) called C<some_expensive_operation()>
+which performs an expensive calculation and can produce many, many results. If
+you call the function on its own and never use its return value, you've called
+the function in I<void context>:
=begin programlisting
@@ -69,8 +71,8 @@ function in I<scalar context>:
X<list context>
-Assigning the results of calling the function to an array or a list, or using
-it in a list evaluates the function in I<list context>:
+Assigning the results of calling the function to an array (L<arrays>) or a
+list, or using it in a list evaluates the function in I<list context>:
=begin programlisting
@@ -107,11 +109,8 @@ tasks, you can use a one or two-element list.
=end sidebar
Evaluating a function or expression--except for assignment--in list context can
-produce confusion. Remember that argument lists and lists
-themselves--especially lists used in hash initializers--propagate list context
-to the expressions they contain. Thus both of these calls to
-C<some_expensive_operation()> are in list context, even if it's not immediately
-obvious:
+produce confusion. Lists propagate list context to the expressions they
+contain. Both calls to C<some_expensive_operation()> occur in list context:
=begin programlisting
@@ -128,9 +127,8 @@ obvious:
X<operators; scalar>
X<scalar>
-The latter example probably will not do what you expect, at least if you expect
-it to return a single item. Use the C<scalar> operator to enforce scalar
-context on the function call:
+The latter example often surprises novice programmers who expect scalar context
+for the call. Use the C<scalar> operator to enforce it:
=begin programlisting
@@ -38,9 +38,12 @@ immediately. Some of Perl's features interact in subtle ways.
=begin sidebar
-You don't have to understand all of the details of this chapter immediately to
-be productive with Perl, but you should be aware of the broad principles as you
-read the rest of this book.
+Learning Perl is like learning a second or third spoken language. You'll learn
+a few words, then string together some sentences, and eventually will be able
+to have small, simple conversations. Mastery comes with practice, both reading
+and writing. You don't have to understand all of the details of this chapter
+immediately to be productive with Perl. Keep the principles as you read the
+rest of this book.
=end sidebar
View
@@ -4,11 +4,12 @@ Z<perldoc>
One of Perl's most useful and least appreciated features is the C<perldoc>
utility. This program is part of every complete Perl 5 installationN<You may
-have to install an additional package on a free Unix-like system; on Debian and
-Ubuntu this is C<perl-doc>.>. It displays the documentation of every Perl
-module installed on the system--whether a core module or one installed from the
-Comprehensive Perl Archive Network (CPAN)--as well as thousands of pages of
-Perl's copious core documentation.
+have to install an additional package on a free GNU/Linux distribution or
+another Unix-like system; on Debian and Ubuntu this is C<perl-doc>.>. It
+displays the documentation of every Perl module installed on the
+system--whether a core module or one installed from the Comprehensive Perl
+Archive Network (CPAN)--as well as thousands of pages of Perl's copious core
+documentation.
=begin sidebar

0 comments on commit 934b7d7

Please sign in to comment.