Skip to content

Commit

Permalink
Give my commitbit a workout on typos and grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
eternaleye committed Nov 26, 2009
1 parent fcde9ac commit af85b7a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/basics.pod
Expand Up @@ -111,12 +111,15 @@ Arrays and Hashes. How should I write that instead? Would "Variables starting
with a dollar are the most permissive, and can hold an arbitrary object" be
better? --moritz

I personally would rather use the symbol than the name of the symbol, because
the array and hash entries later on do so. --eternaleye

=end for

X<files; handle>
X<file handle>

Each sigil carries a meaning. Variables starting with a dollar can hold
Each sigil carries a meaning. Variables with the C<$> sigil can hold
arbitrary values. The built-in function C<open> opens a file, here named
F<scores>, and returns an object describing that file, a I<file handle>. The
equality sign C<=> I<assigns> that file handle to the variable on the left,
Expand All @@ -143,8 +146,8 @@ line ending. C<split> is also a method, called on the string returned from
C<get>. C<split>'s single argument is a string containing a space character.
C<split> decomposes its invocant string into a list of strings. It turns
C<'Beth Ana Charlie Dave'> into C<'Beth', 'Ana', 'Charlie', 'Dave'>. Finally,
this list gets stored into the array C<@names>. The C<@> sigil makes the
declared variable an C<Array>. Arrays store ordered lists.
this list gets stored into the array C<@names>. The C<@> sigil marks the
declared variable as an C<Array>. Arrays store ordered lists.

=begin programlisting

Expand All @@ -157,11 +160,11 @@ X<hash>

These two lines of code declare two hashes. A C<Hash> is an unordered
collection of pairs of keys and values. Other programming languages call that a
I<hash table>, I<dictionary>, or I<map>. You can ask query a hash table for the
I<hash table>, I<dictionary>, or I<map>. You can query a hash table for the
value that corresponds to a certain C<$key> with C<%hash{$key}>.

Here in the score counting program, C<%games> stores the number of won games
per player and C<%sets> the number of won sets per player.
Here in the score counting program, C<%games> stores the number of games each
player has won and C<%sets> the number of sets each player has won.

=begin programlisting

Expand Down Expand Up @@ -314,7 +317,7 @@ key and value in a C<Pair>.)
If C<$r1> has a larger value than C<$r2>, C<%games{$p1}> increments by one. If
C<$r1> is not larger than C<$r2>, C<%games{$p2}> increments. If either hash
value did not exist previously, it springs into existence from the increment
operation.
operation. This is called I<autovivification>.

X<postincrement>
X<operators; postincrement>
Expand Down Expand Up @@ -369,7 +372,7 @@ first by the number of sets won (the secondary criterion), then by the number
of games won.

After the first sorting step the names are in the order C<Beth Charlie Dave
Ana>. After the second sorting step, it's again the same, because nobody has
Ana>. After the second sorting step, it's still the same, because nobody has
won fewer games but more sets than somebody else. Such a situation is
entirely possible, especially at larger tournaments.

Expand Down Expand Up @@ -408,13 +411,13 @@ X<single-quoted strings>
X<strings; single-quoted>

This interpolation happens only in strings delimited by double quotes
C<"...">. Single quoted strings C<'...> do not interpolate:
C<"...">. Single quoted strings C<'...'> do not interpolate:

=begin programlisting

my $names = 'things';
say 'Do not call me $names';
say "Do not call me $names';
say "Do not call me $names";
say 'Math: { 1 + 2 }'
say "Math: { 1 + 2 }"

Expand Down

0 comments on commit af85b7a

Please sign in to comment.