Skip to content

Commit

Permalink
Applied edits from Mike Huffman.
Browse files Browse the repository at this point in the history
  • Loading branch information
chromatic committed Sep 23, 2010
1 parent 4a220d1 commit 79c1dc1
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CREDITS
Expand Up @@ -170,3 +170,6 @@ E: makamaal.linux@gmail.com

N: Christopher E. Stith
E: cstith@gmail.com

N: Mike Huffman
E: mhuffman@aracnet.com
11 changes: 10 additions & 1 deletion sections/control_flow.pod
Expand Up @@ -282,9 +282,14 @@ subsequent subexpressions. This is most obvious with an example:

=begin programlisting

# see preface
use Test::More 'no_plan';

say "Both true!" if ok(1, 'first subexpression')
&& ok(1, 'second subexpression');

done_testing();

=end programlisting

=begin sidebar
Expand Down Expand Up @@ -540,7 +545,11 @@ You cannot use aliasing to modify I<constant> values, however:

=begin programlisting

lc for qw( Huey Dewey Louie );
for (qw( Huex Dewex Louie ))
{
$_++;
say;
}

=end programlisting

Expand Down
14 changes: 12 additions & 2 deletions sections/hashes.pod
Expand Up @@ -247,8 +247,18 @@ contains the given key:
Using C<exists> instead of accessing the hash key directly avoids two problems.
First, it does not check the boolean nature of the hash I<value>; a hash key
may exist with a value even if that value evaluates to a boolean false
(including C<undef>). Second, with nested data structures, it avoids
autovivifying (L<autovivification>) the value.
(including C<undef>):

=begin programlisting

my %false_key_value = ( 0 => '' );
ok( %false_key_value,
'hash containing false key & value should evaluate to a true value' );

=end programlisting

Second, with nested data structures, C<exists> avoids autovivifying
(L<autovivification>) the value.

X<defined>
X<operators; defined>
Expand Down
4 changes: 2 additions & 2 deletions sections/references.pod
Expand Up @@ -80,7 +80,7 @@ dereferencing:
sub reverse_in_place
{
my $name_ref = shift;
reverse B<$$name>;
reverse B<$$name_ref>;
}

my $name = 'Blabby';
Expand Down Expand Up @@ -109,7 +109,7 @@ messy:
sub reverse_in_place
{
my $name_ref = shift;
reverse B<${ $name }>;
reverse B<${ $name_ref }>;
}

=end programlisting
Expand Down
2 changes: 1 addition & 1 deletion sections/scalars.pod
Expand Up @@ -58,7 +58,7 @@ You may also perform mathematical operations on strings:

=begin programlisting

my $call_sign = 'KB7MIU';
my $call_sign = 'KBMIU';
my $next_sign = $call_sign++;

# also fine as
Expand Down
9 changes: 9 additions & 0 deletions sections/values.pod
Expand Up @@ -749,6 +749,9 @@ context (for a single element) or list context (for a slice):

=begin programlisting

# enable say and other features (see preface)
use Modern::Perl;

# you do not need to understand this all
sub context
{
Expand All @@ -766,4 +769,10 @@ context (for a single element) or list context (for a slice):
my @array_slice = @list_slice[context()];
my $array_index = $array_slice[context()];

# say imposes list context
say context();

# void context is obvious
context()

=end programlisting

0 comments on commit 79c1dc1

Please sign in to comment.