|
Manipulate or Combine elements to an array in different ways.
@CombinedArray = (@Array1, @Array2);
Using the above code, the resulting array contains all the elements in @Array1, followed by that of @Array2. To append
a scalar element to the end of an array, you can write, for example,
@MyArray = (@MyArray, $NewElement);
Example to Manipulate Arrays:
#! C:\programfiles\perl\bin\perl
print "content-type: text/html\n\n";
@array1 = ("red", "green");
@array2 = ("blue", "white");
@combined = (@array1, @array2);
$, = "\n";
print @combined;
print "<br>";
@new = (@combined,orange);
$, = "\n";
print @new;
Result:
red green blue white
red green blue white orange
In the above manipulation example, first two arrays "array1","array2" are combined, then a new element "orange" is added to the
existing array as it is a scalar element.
|