- 论坛徽章:
- 145
|
回复 7# emlin129
基础...
$ perldoc perldata
NAME
perldata - Perl data types
DESCRIPTION
Variable names
Perl has three built-in data types: scalars, arrays of scalars, and
associative arrays of scalars, known as "hashes". A scalar is a single
string (of any size, limited only by the available memory), number, or a
reference to something (which will be discussed in perlref). Normal arrays
are ordered lists of scalars indexed by number, starting with 0. Hashes
are unordered collections of scalar values indexed by their associated
string key.
...
Scalar values are always named with '$', even when referring to a scalar
that is part of an array or a hash. The '$' symbol works semantically like
the English word "the" in that it indicates a single value is expected.
$days # the simple scalar value "days"
$days[28] # the 29th element of array @days
$days{'Feb'} # the 'Feb' value from hash %days
$#days # the last index of array @days
Entire arrays (and slices of arrays and hashes) are denoted by '@', which
works much as the word "these" or "those" does in English, in that it
indicates multiple values are expected.
@days # ($days[0], $days[1],... $days[n])
@days[3,4,5] # same as ($days[3],$days[4],$days[5])
@days{'a','c'} # same as ($days{'a'},$days{'c'})
|
|