# @arrayname = ("element1", "element2");
# an array can have as many elements as it wants
@browser=("NS", "IE", "NaviBrowse", "Goupa");
# USING AN ARRAY
# Let's try to grab IE from the array above
$browser[1];
# We get values from the array by assigning a variable with the same
name as the array and
# the number of the value we want in the array. in the definition
of the example array,
# we have 4 values; each value has a number starting with 0.
So the numbers for the ex
# array are 0-3
# NS IE NaviBrowse Goupa
# 0 1 2 3
#
# You can change and add elements to arrays. Here's how:
@browser=("NS", "IE", "NaviBrowse", "Goupa");
$browser[2]="Mosaic";
# "NaviBrowse" (third element) has been changed to "Mosaic"
#
# You can add elements to the last position of the array like this:
@browser=("NS", "IE", "Mosaic", "Goupa");
$browser[4]="NaviBrowse";
#To delete an element from an array:
@browser=("NS", "IE", "Mosaic", "Goupa");
splice(@browser, 1, 1);
# This uses the SPLICE function. See functions.pl for syntax
# The first element starting at position 1 has been deleted, so the
array would be:
@browser=("NS", "Mosaic", "Goupa");
# You can replace elements in an array also with the SPLICE function like this:
@browser = ("NS", "IE", "Opera");
splice(@browser, 1, 2, "NeoPlanet", "Mosaic");
# This replaces "IE" and "Opera" with "NeoPlanet" and "Mosaic"
print @browser;