1.array indexing:
$array[0] # the first element.
$array[1] # the second element.
$array[-1] # the last element.
$array[-2] # the 2nd to last element.
2. sequential number array
@array[1 .. 100];
@array["a" .. "z"]
3. finding the length of an array
scalar ( @array );
$len = @array;
4. adding and removing an element
push @array , $element; --> add an element to the end of an array
$element = pop @array ; --> remove the last element of an array
unshift @array , $element ; --> add an element to the begining of an array
$element = shift @array; --> remove the first element of an array
delete @array[$index]--> remove an element by index number
5. split a string to array and join an array into a string
split /pattern/, string, @array --> split the string into a string list and return the list.
join $exp , @array --> join the sperated strings of @array into a new string with field sperated by
the value of $exp, and return the new string .
6. sort an array
sort @array;
7. foreach $element (@array);
$array[0] # the first element.
$array[1] # the second element.
$array[-1] # the last element.
$array[-2] # the 2nd to last element.
2. sequential number array
@array[1 .. 100];
@array["a" .. "z"]
3. finding the length of an array
scalar ( @array );
$len = @array;
4. adding and removing an element
push @array , $element; --> add an element to the end of an array
$element = pop @array ; --> remove the last element of an array
unshift @array , $element ; --> add an element to the begining of an array
$element = shift @array; --> remove the first element of an array
delete @array[$index]--> remove an element by index number
5. split a string to array and join an array into a string
split /pattern/, string, @array --> split the string into a string list and return the list.
join $exp , @array --> join the sperated strings of @array into a new string with field sperated by
the value of $exp, and return the new string .
6. sort an array
sort @array;
7. foreach $element (@array);