$#days # the last index of array @days
Entire arrays (and slices of arrays and hashes) are denoted by '@',
-which works much like the word "these" or "those" does in English,
+which works much as the word "these" or "those" does in English,
in that it indicates multiple values are expected.
X<array>
scalar evaluates the right-hand side in scalar context, while
assignment to an array or hash evaluates the righthand side in list
context. Assignment to a list (or slice, which is just a list
-anyway) also evaluates the righthand side in list context.
+anyway) also evaluates the right-hand side in list context.
When you use the C<use warnings> pragma or Perl's B<-w> command-line
option, you may see warnings
%HASH in scalar context reveals C<"1/16">, which means only one out
of sixteen buckets has been touched, and presumably contains all
10,000 of your items. This isn't supposed to happen. If a tied hash
-is evaluated in scalar context, a fatal error will result, since this
-bucket usage information is currently not available for tied hashes.
+is evaluated in scalar context, the C<SCALAR> method is called (with a
+fallback to C<FIRSTKEY>).
X<hash, scalar context> X<hash, bucket> X<bucket>
You can preallocate space for a hash by assigning to the keys() function.
Note that since Perl 5.8.1 the single-number v-strings (like C<v65>)
are not v-strings before the C<< => >> operator (which is usually used
-to separate a hash key from a hash value), instead they are interpreted
+to separate a hash key from a hash value); instead they are interpreted
as literal strings ('v65'). They were v-strings from Perl 5.6.0 to
Perl 5.8.0, but that caused more confusion and breakage than good.
Multi-number v-strings like C<v65.66> and C<65.66.67> continue to
point in your program. They may be used only as separate tokens; they
will not be interpolated into strings. If there is no current package
(due to an empty C<package;> directive), __PACKAGE__ is the undefined
-value.
+value. (But the empty C<package;> is no longer supported, as of version
+5.10.)
X<__FILE__> X<__LINE__> X<__PACKAGE__> X<line> X<file> X<package>
The two control characters ^D and ^Z, and the tokens __END__ and __DATA__
Text after __DATA__ may be read via the filehandle C<PACKNAME::DATA>,
where C<PACKNAME> is the package that was current when the __DATA__
token was encountered. The filehandle is left open pointing to the
-contents after __DATA__. It is the program's responsibility to
+line after __DATA__. It is the program's responsibility to
C<close DATA> when it is done reading from it. For compatibility with
older scripts written before __DATA__ was introduced, __END__ behaves
like __DATA__ in the top level script (but not in files loaded with
end of the enclosing block. An inner block may countermand this
by saying C<no strict 'subs'>.
-=head3 Array Joining Delimiter
+=head3 Array Interpolation
X<array, interpolation> X<interpolation, array> X<$">
Arrays and slices are interpolated into double-quoted strings
=head2 Subscripts
-An array is subscripted by specifying a dollar sign (C<$>), then the
+An array can be accessed one scalar at a
+time by specifying a dollar sign (C<$>), then the
name of the array (without the leading C<@>), then the subscript inside
square brackets. For example:
print "Darwin's First Name is ", $scientists{"Darwin"}, "\n";
-=head2 Slices
-X<slice> X<array, slice> X<hash, slice>
+You can also subscript a list to get a single element from it:
+
+ $dir = (getpwnam("daemon"))[7];
+
+=head2 Multi-dimensional array emulation
+
+Multidimensional arrays may be emulated by subscripting a hash with a
+list. The elements of the list are joined with the subscript separator
+(see L<perlvar/$;>).
-A common way to access an array or a hash is one scalar element at a
-time. You can also subscript a list to get a single element from it.
+ $foo{$a,$b,$c}
- $whoami = $ENV{"USER"}; # one element from the hash
- $parent = $ISA[0]; # one element from the array
- $dir = (getpwnam("daemon"))[7]; # likewise, but with list
+is equivalent to
+
+ $foo{join($;, $a, $b, $c)}
+
+The default subscript separator is "\034", the same as SUBSEP in B<awk>.
+
+=head2 Slices
+X<slice> X<array, slice> X<hash, slice>
A slice accesses several elements of a list, an array, or a hash
simultaneously using a list of subscripts. It's more convenient
Another way to create anonymous filehandles is with the Symbol
module or with the IO::Handle module and its ilk. These modules
have the advantage of not hiding different types of the same name
-during the local(). See the bottom of L<perlfunc/open()> for an
+during the local(). See the bottom of L<perlfunc/open> for an
example.
=head1 SEE ALSO