Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Applied edits from Alexander Scott-Johns.

  • Loading branch information...
commit 95704ce7da276c970e63a5c3d28be754a5b58f0f 1 parent 2288428
@chromatic authored
View
3  CREDITS
@@ -152,3 +152,6 @@ E: deeelwy@yahoo.com
N: Marko Zagožen
E:-?
+
+N: Alexander Scott-Johns
+E: alexander.scott.johns@googlemail.com
View
2  sections/context_philosophy.pod
@@ -32,7 +32,7 @@ string value, or a value that's either true or false.
Context can be tricky if you try to write or read Perl code as a series of
single expressions which stand apart from from their environments. You may
-find yourself slapping your forehead after a long debugging session when you
+find yourself slapping your forehead after a long debugging session when you
discover that your assumptions about context were incorrect. However, if you're
cognizant of contexts, they can make your code clearer, more concise, and more
flexible.
View
36 sections/control_flow.pod
@@ -400,12 +400,12 @@ Z<looping_directives>
Perl also provides several directives for looping and iteration.
-C<foreach>
-C<for>
-C<looping directives; for>
-C<looping directives; foreach>
+X<foreach>
+X<for>
+X<looping directives; for>
+X<looping directives; foreach>
-The I<foreach> style loop evaluates an expression which produces a list and
+The I<foreach>-style loop evaluates an expression which produces a list and
executes a statement or block until it has consumed that list:
=begin programlisting
@@ -417,19 +417,30 @@ executes a statement or block until it has consumed that list:
=end programlisting
-This example uses the C<range> operator to produce a list of integers from one
+This example uses the range operator to produce a list of integers from one
to ten inclusive. The C<foreach> directive loops over them, setting the topic
variable (C<$_>) to each in turn. Perl executes the block for each integer and
prints the squares of the integers.
=begin sidebar
-Though this is a I<foreach>-style loop, Perl treats the keywords C<foreach> and
-C<for> interchangeably. As only the I<type> of the loop governs its behavior,
-there are no drawbacks to using the shorter C<for> keyword.
+Note that this is described as a I<foreach>-I<style> loop: Perl treats the
+keywords C<foreach> and C<for> interchangeably. As only the I<type> of the
+loop governs its behavior, there are no drawbacks to using the shorter C<for>
+keyword.
=end sidebar
+=for author
+
+Previous paragraph:
+ "As only the I<type> of the..."
+
+What does "type" mean here? Whether the variable is scalar or array? Or
+syntactic type? (Whatever that means.)
+
+=end for
+
Like C<if> and C<unless>, the C<for> loop has a postfix form:
=begin programlisting
@@ -1185,6 +1196,13 @@ optimization>.
Perl 5 cannot perform this optimization automatically, but you can perform it
manually.
+=for author
+
+What does that mean? Perl won't automatically rearrange your code into a
+tail recursive form, but will automatically detect when it is in that form?
+
+=end for
+
=begin sidebar
Heavily recursive code (L<recursion>), especially mutually recursive code, can
View
7 sections/hashes.pod
@@ -76,7 +76,7 @@ required pairing more visible:
The fat comma operator acts like the regular comma, but it also causes the Perl
parser to treat the previous bareword (L<barewords>) as if it were a quoted
-word. The C<strict> pragma will not warn about the bare word, and if you have
+word. The C<strict> pragma will not warn about the bareword, and if you have
a function with the same name as a hash key, the fat comma will I<not> call the
function:
@@ -452,9 +452,8 @@ meaningless to Perl programs. You can safely ignore it.
In list context, a hash evaluates to a list of key/value pairs similar to what
you receive from the C<each> operator. However, you I<cannot> iterate over
-this list the same way you can iterate over the list produced by C<each>,
-because there is no internal hash iteration provided when evaluating a hash in
-list contextN<The loop will loop forever, unless the hash is empty.>.
+this list the same way you can iterate over the list produced by C<each>.N<The
+loop will loop forever, unless the hash is empty.>.
=head2 Hash Idioms
View
4 sections/perl_community.pod
@@ -87,8 +87,8 @@ X<Gitpan>
Many Perl hackers use Github (U<http://github.com/>) to host their
projectsN<... including the drafts of this book at
-U<http://github.com/chromatic/modern_perl_book/>)>. One particularly notable
-page on Github is Gitpan, which hosts Git repositories chronicling the complete
+U<http://github.com/chromatic/modern_perl_book/>)>. One particularly notable
+page on Github is Gitpan, which hosts Git repositories chronicling the complete
history of every distribution on the CPAN. See U<http://github.com/gitpan/>.
=head1 Events
View
24 sections/values.pod
@@ -32,7 +32,21 @@ program until you give it meaning. A string is a fixed amount of data
delineated by quotes of some form, yet Perl strings can grow or shrink as you
add to or remove from them.
-Most strings use either single or double quotes:
+=for author
+
+ "...and no semantic meaning beyond the fact that it's a string."
+Not that any data in any program has intrinsic semantic meaning... Humans
+provide that.
+
+You haven't explained what a string actually _is_ yet: text or binary data.
+It is explained lower down, in the "Unicode and Strings" section.
+
+ "...Perl strings can grow or shrink as you add to or remove from them."
+Perl strings are values, and so are immutable, aren't they?
+
+=end for
+
+The most common string delimiters are single and double quotes:
=begin programlisting
@@ -59,7 +73,7 @@ single quote:
=begin programlisting
- my $exception = 'This string ends with a backslash, not a quote: \\';
+ my $exception = 'This string ends with a backslash, not a quote: B<\\>';
=end programlisting
@@ -70,7 +84,7 @@ next to each other, the first one will escape the the second one.
=begin programlisting
- is('Modern \ Perl', 'Modern \\ Perl', 'single quotes backslash escaping');
+ is('Modern B<\> Perl', 'Modern B<\\> Perl', 'single quotes backslash escaping');
=end programlisting
@@ -556,8 +570,8 @@ C<perldoc perlnumber> for more details.
You may not use commas to separate thousands in numeric literals because the
parser will interpret the commas as comma operators. You I<can> use
-underscores in other places within the number, however. The parser will treat
-them as invisible characters. Your readers may not. These are equivalent:
+underscores within the number, however. The parser will treat them as
+invisible characters; your readers may not. These are equivalent:
=begin programlisting
View
15 sections/variables.pod
@@ -67,16 +67,27 @@ I<anonymous> variables. The only way to access them is by reference
X<variables; types>
X<types; containers>
X<types; variables>
-X<container types>
+X<container type>
+X<value type>
Perl 5 variables do not enforce types on their values. You may store a string
in a variable in one line, append to that variable a number on the next, and
reassign a reference to a function (L<function_references>) on the third. The
-types of the I<values> is flexible (or dynamic), but the type of the
+types of the I<values> are flexible (or dynamic), but the type of the
I<variable> is static. A scalar variable can only hold scalars. An array
variable only contains a list. A hash variable must contain an even-sized list
of key/value pairs.
+=begin sidebar
+
+It may seem strange to talk about I<type> in two different terms: what kind of
+variable you have and what kind of data you have, but Perl makes that
+distinction. It's clearest to refer to these two types of types as I<container
+type> and I<value type>.
+
+=end sidebar
+
+
Assigning to a variable may cause coercion (L<coercion>). The documented way
to determine the number of entries in an array is to evaluate that array in
scalar context (L<context_philosophy>). Because a scalar variable can only

0 comments on commit 95704ce

Please sign in to comment.
Something went wrong with that request. Please try again.