Skip to content

Commit f93ae73

Browse files
committed
perldata: Define 'sigil', and use this term
Also note that the may be blanks between a sigil and the name. This fixes #19096.
1 parent ebcd258 commit f93ae73

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

pod/perldata.pod

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ values indexed by their associated string key.
1717

1818
Values are usually referred to by name, or through a named reference.
1919
The first character of the name tells you to what sort of data
20-
structure it refers. The rest of the name tells you the particular
20+
structure it refers. This character is called a "sigil". The rest of
21+
the name tells you the particular
2122
value to which it refers. Usually this name is a single I<identifier>,
2223
that is, a string beginning with a letter or underscore, and
2324
containing letters, underscores, and digits. In some cases, it may
@@ -28,8 +29,9 @@ to locate the namespace in which to look up the final identifier
2829
on identifiers, see L</Identifier parsing>. It's possible to
2930
substitute for a simple identifier, an expression that produces a reference
3031
to the value at runtime. This is described in more detail below
31-
and in L<perlref>.
32-
X<identifier>
32+
and in L<perlref>. It is legal, but not recommended, to separate a
33+
variable's sigil from its name by space and/or tab characters.
34+
X<identifier> X<sigil>
3335

3436
Perl also has its own built-in variables whose names don't follow
3537
these rules. They have strange names so they don't accidentally
@@ -41,7 +43,7 @@ the inner working of Perl have names containing punctuation characters.
4143
These are documented in L<perlvar>.
4244
X<variable, built-in>
4345

44-
Scalar values are always named with '$', even when referring to a
46+
Scalar values are always named with the sigil '$', even when referring to a
4547
scalar that is part of an array or a hash. The '$' symbol works
4648
semantically like the English word "the" in that it indicates a
4749
single value is expected.
@@ -52,21 +54,21 @@ X<scalar>
5254
$days{'Feb'} # the 'Feb' value from hash %days
5355
$#days # the last index of array @days
5456

55-
Entire arrays (and slices of arrays and hashes) are denoted by '@',
56-
which works much as the word "these" or "those" does in English,
57+
Entire arrays (and slices of arrays and hashes) are denoted by the sigil
58+
'@', which works much as the word "these" or "those" does in English,
5759
in that it indicates multiple values are expected.
5860
X<array>
5961

6062
@days # ($days[0], $days[1],... $days[n])
6163
@days[3,4,5] # same as ($days[3],$days[4],$days[5])
6264
@days{'a','c'} # same as ($days{'a'},$days{'c'})
6365

64-
Entire hashes are denoted by '%':
66+
Entire hashes are denoted by the sigil '%':
6567
X<hash>
6668

6769
%days # (key1, val1, key2, val2 ...)
6870

69-
In addition, subroutines are named with an initial '&', though this
71+
In addition, subroutines are named with an initial sigil '&', though this
7072
is optional when unambiguous, just as the word "do" is often redundant
7173
in English. Symbol table entries can be named with an initial '*',
7274
but you don't really care about that yet (if ever :-).
@@ -81,8 +83,9 @@ is a part of @foo, not a part of $foo. This may seem a bit weird,
8183
but that's okay, because it is weird.
8284
X<namespace>
8385

84-
Because variable references always start with '$', '@', or '%', the
85-
"reserved" words aren't in fact reserved with respect to variable
86+
Because variable references always start with the sigils '$', '@', or
87+
'%', the "reserved" words aren't in fact reserved with respect to
88+
variable
8689
names. They I<are> reserved with respect to labels and filehandles,
8790
however, which don't have an initial special character. You can't
8891
have a filehandle named "log", for instance. Hint: you could say

0 commit comments

Comments
 (0)