Skip to content

Commit

Permalink
[basics] add some verbage on scopes and sigils
Browse files Browse the repository at this point in the history
  • Loading branch information
perlpilot committed Mar 13, 2011
1 parent a9d478b commit d9d8f42
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/basics.pod
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,23 @@ X<lexical>
X<variables, lexical>
X<block>

C<my> declares a lexical variable. Lexical variables are visible only in
the current block. If there's no enclosing block, it's visible throughout the
remainder of the file. A block is any part of the code enclosed between curly
braces { }.
C<my> declares a lexical variable. Lexical variables are visible only
in the current block from the point of declaration to the end of the
block. If there's no enclosing block, it's visible throughout the
remainder of the file. A block is any part of the code enclosed between
curly braces { }.

X<sigil>
X<identifier>

A variable name begins with a I<sigil>, which is non-alpha-numeric symbol
such as
C<$>, C<@>, C<%>, or C<&>--or occasionally the double colon C<::>. The sigils
usually restrict the variable to a particular type, such as a single value or a
compound value. After the sigil comes an I<identifier>, which may consist of
letters, digits and the underscore. Between letters you can also use a dash
C<-> or an apostrophe C<'>, so C<isn't> and C<double-click> are valid
identifiers.
A variable name begins with a I<sigil>, which is non-alpha-numeric
symbol such as C<$>, C<@>, C<%>, or C<&>--or occasionally the double
colon C<::>. Sigils indicate the structural interface for the variable,
such as whether it should be treated as a single value or a compound value
or a subroutine, etc. After the sigil comes an I<identifier>, which may
consist of letters, digits and the underscore. Between letters you can
also use a dash C<-> or an apostrophe C<'>, so C<isn't> and C<double-
click> are valid identifiers.

X<variable, scalar>
X<scalar>
Expand Down Expand Up @@ -182,6 +183,13 @@ C<[ ]> or C<{ }>. This is called I<M<sigil invariance>>.>.
In the score counting program, C<%matches> stores the number of matches each
player has won. C<%sets> stores the number of sets each player has won.


=for author

The following paragraph seems out of place.

=end

Sigils indicate the default access method for a variable. Variables
with the C<@> sigil are accessed positionally; variables with the C<%>
sigil are accessed by string key. The C<$> sigil, however, indicates a
Expand Down

0 comments on commit d9d8f42

Please sign in to comment.