perldoc perlfunc |grep -i array An named array in scalar context is quite different from what would at Functions for real @ARRAYs "last", "next", "redo", "return", "sub", "wantarray" "reset", "scalar", "undef", "wantarray" $wantarray, $evaltext, $is_require, $hints, $bitmask) = caller($i); @array = split(/:/); returns "undef" when its argument is an empty array, *or* when Use of "defined" on aggregates (hashes and arrays) is if (@an_array) { print "has array elements\n" } Given an expression that specifies a hash element, array element, hash slice, or array slice, deletes the specified element(s) from the hash or array. In the case of an array, if the array elements happen to be at the end, the size of the array will shrink to the highest element that tests true for entry from the DBM file. Deleting from a "tie"d hash or array Deleting an array element effectively returns that position of the array to its initial, uninitialized state. Subsequently Note that deleting array elements in the middle of an array will and @ARRAY: foreach $index (0 .. $#ARRAY) { delete $ARRAY[$index]; delete @ARRAY[0 .. $#ARRAY]; or undefining %HASH or @ARRAY: @ARRAY = (); # completely empty @ARRAY undef @ARRAY; # forget @ARRAY ever existed final operation is a hash element, array element, hash slice, or array slice lookup: When the hash is entirely read, a null array is returned in list "wantarray" for more on how the evaluation context can be array with more than one value, calls execvp(3) with the array with one element in it, the argument is checked for shell Given an expression that specifies a hash element or array array has ever been initialized, even if the corresponding value print "Exists\n" if exists $array[$index]; print "Defined\n" if defined $array[$index]; print "True\n" if $array[$index]; A hash or array element can be true only if it's defined, and final operation is a hash or array key lookup or subroutine Although the deepest nested array or hash will not spring into See "Pseudo-hashes: Using an array as a hash" in perlref for an "@" character may be taken to mean the beginning of an array (This is similar to pre-extending an array by assigning a larger number to $#array.) If you say on an entire array or hash to find out how many elements these have. For that, use "scalar @array" and "scalar keys %hash" with tied arrays and hashes. %hash = map { getkey($_) => $_ } @array; foreach $_ (@array) { array composed of those items of the original list for which the %hash = map { "\L$_", 1 } @array # perl guesses EXPR. wrong %hash = map { +"\L$_", 1 } @array # perl guesses BLOCK. right %hash = map { ("\L$_", 1) } @array # this also works %hash = map { lc($_), 1 } @array # as does this. %hash = map +( lc($_), 1 ), @array # this is EXPR and works! %hash = map ( lc($_), 1 ), @array # evaluates to (1, @array) @hashes = map +{ lc($_), 1 }, @array # EXPR, so needs , at end pop ARRAY pop Pops and returns the last value of the array, shortening the array by one element. Has an effect similar to $ARRAY[$#ARRAY--] If there are no elements in the array, returns the undefined ARRAY is omitted, pops the @ARGV array in the main program, and the @_ array in subroutines, just like "shift". Note that if you're storing FILEHANDLES in an array or other push ARRAY,LIST Treats ARRAY as a stack, and pushes the values of LIST onto the end of ARRAY. The length of ARRAY increases by the length of $ARRAY[++$#ARRAY] = $value; array. ARRAY file in the directories specified in the @INC array. @INC array and will complain about not finding "Foo::Bar" there. (hyphens allowed for ranges). All variables and arrays beginning @ARGV and @INC arrays and your %ENV hash. Resets only package "wantarray"). If no EXPR is given, returns an empty list in list the returned semid_ds structure or semaphore value array. packed array of semop structures. Each semop structure can be shift ARRAY shift Shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down. If there are no elements in the array, returns the undefined value. If ARRAY is omitted, shifts the @_ array within the lexical scope of subroutines and formats, and the @ARGV array at file scopes the same thing to the left end of an array that "pop" and "push" splice ARRAY,OFFSET,LENGTH,LIST splice ARRAY,OFFSET,LENGTH splice ARRAY,OFFSET splice ARRAY array, and replaces them with the elements of LIST, if any. In list context, returns the elements removed from the array. In no elements are removed. The array grows or shrinks as the end of the array. If LENGTH is omitted, removes everything elements off the end of the array. If both OFFSET and LENGTH are Example, assuming array lengths are passed before arrays: into the @_ array. Use of split in scalar context is deprecated, when you pass it an array as your first argument. The array is the array as the format, Perl will use the count of elements in the array as the format, which is almost never useful. argument in LIST, or if LIST is an array with more than one "TIESCALAR", "TIEHANDLE", "TIEARRAY", or "TIEHASH"). Typically A class implementing an ordinary array should have the following TIEARRAY classname, LIST perltie, Tie::Hash, Tie::Array, Tie::Scalar, and Tie::Handle. on a scalar value, an array (using "@"), a hash (using "%"), a return (wantarray ? (undef, $errmsg) : undef) if $they_blew_it; unshift ARRAY,LIST the array, and returns the new number of elements in the array. wantarray return unless defined wantarray; # don't bother doing more return wantarray ? @a : "@a";