Array Functions
@array = ( ); Defines an empty array
@array = (“a”, “b”, “c”); Defines an array with values
$array[0] The first element of @array
$array[0] = a; Sets the first element of @array to a
@array[3..5] Array slice - returns a list containing the 3rd thru 5th
elements of @array
scalar(@array) Returns the number of elements in @array
$#array The index of the last element in @array
grep(/pattern/, @array) Returns a list of the items in @array that matched
/pattern/
join(expr, @array) Joins @array into a single string separated by expr
push(@array, $var) Adds $var to @array
pop(@array) Removes last element of @array and returns it
reverse(@array) Returns @array in reverse order
shift(@array) Removes first element of @array and returns it
sort(@array) Returns alphabetically sorted @array
sort({$a<=>$b}, @array) Returns numerically sorted @array
Hash Functions
%hash = ( ); Defines an empty hash
%hash = (a => 1, b=>2); Defines a hash with values
$hash{$key} The value referred to by this $key
$hash{$key} = $value; Sets the value referred to by $key
exists $hash{$key} True if the key/value pair exists
delete $hash{$key} Deletes the key/value pair specified by $key
keys %hash Returns a list of the hash keys values %hash Returns a list of the hash values