Skip to content

Commit

Permalink
Applied edits from Andrew Grangaard.
Browse files Browse the repository at this point in the history
  • Loading branch information
chromatic committed Oct 7, 2010
1 parent 87da6f2 commit 29f7024
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CREDITS
Expand Up @@ -194,3 +194,6 @@ E: rlhicks@wehicks.com

N: Chris Niswander
E: cnp1@chrisniswander.com

N: Andrew Grangaard
E: spazm@cpan.org
5 changes: 3 additions & 2 deletions sections/coercion.pod
Expand Up @@ -23,8 +23,9 @@ X<truthiness>
Boolean coercion occurs when you test the I<truthiness> of a valueN<Truthiness
is like truthfulness if you squint and say "Yeah, that's true, but....">, such
as in a C<if> or C<while> condition. Numeric 0 is false. The undefined value
is false. The empty string is false, and so is the string C<'0'>. The strings
C<'0.0'> and C<'0e'> are I<true>, however.
is false. The empty string is false, and so is the string C<'0'>. Strings
which may be I<numerically> equal to zero (such as C<'0.0'>, C<'0e'>, and C<'0
but true'>) are I<true>, however.

All other values are true, including the idiomatic string C<'0 but true'>. In
the case of a scalar with both string and numeric portions (L<dualvars>), Perl
Expand Down
14 changes: 8 additions & 6 deletions sections/control_flow.pod
Expand Up @@ -261,7 +261,8 @@ select between alternative I<variables>, not only values:

=begin programlisting

push @{ rand() > 0.5 ? \@red_team : \@blue_team }, Player->new();
push @{ rand() > 0.5 ? \@red_team : \@blue_team },
Player->new();

=end programlisting

Expand Down Expand Up @@ -381,11 +382,12 @@ Empty hashes and arrays evaluate to false.

Perl 5 has no single true value, nor a single false value. Any number that
evaluates to 0 is false. This includes C<0>, C<0.0>, C<0e0>, C<0x0>, and so
on. The empty string (C<''>) and C<"0"> evaluate to false, but the strings
C<"0.0">, C<"0e0">, and so on do not. The idiom C<"0 but true"> evaluates to 0
in numeric context but evaluates to true, thanks to its string contents. Both
the empty list and C<undef> evaluate to false. Empty arrays and hashes return
the number 0 in scalar context, so they evaluate to false in boolean context.
on. The empty string (C<''>) and C<'0'> evaluate to false, but the strings
C<'0.0'>, C<'0e0'>, and so on do not. The idiom C<'0 but true'> evaluates to 0
in numeric context but evaluates to true in boolean context, thanks to its
string contents. Both the empty list and C<undef> evaluate to false. Empty
arrays and hashes return the number 0 in scalar context, so they evaluate to
false in boolean context.

An array which contains a single element--even C<undef>--evaluates to true in
boolean context. A hash which contains any elements--even a key and a value of
Expand Down
2 changes: 1 addition & 1 deletion sections/names.pod
Expand Up @@ -20,7 +20,7 @@ identifiers. These are all valid Perl identifiers:

sub anAwkwardName3;

# with C<use utf8;> enabled
# with use utf8; enabled
package Ingy::DE<ouml>t::Net;

=end programlisting
Expand Down
6 changes: 3 additions & 3 deletions sections/references.pod
Expand Up @@ -230,7 +230,7 @@ Surround a list of values or expressions with square brackets:
=end programlisting

This array reference behaves the same as named array references, except that
anonymous array references I<always> create a new reference, while taking a
the anonymous array brackets I<always> create a new reference, while taking a
reference to a named array always refers to the I<same> array with regard to
scoping. That is to say:

Expand All @@ -257,8 +257,8 @@ scoping. That is to say:
=end programlisting

... neither C<$sunday_ref> nor C<$monday_ref> contains a dessert. Within the
square braces used to create the anonymous array reference, the C<@meals> array
flattens in list context.
square braces used to create the anonymous array, the C<@meals> array flattens
in list context.

=head3 Hash References

Expand Down

0 comments on commit 29f7024

Please sign in to comment.