A program that copies an array and compares the elements of the two arrays. : Array Value « Array « Perl






A program that copies an array and compares the elements of the two arrays.

    

#!/usr/local/bin/perl 

@array1 = (14, "abc", 1.23, -7, "def"); 
@array2 = @array1; 
$count = 1; 
while ($count <= 5) { 
    print("element $count: $array1[$count-1] "); 
    print("$array2[$count-1]\n"); 
    $count++; 
} 

   
    
    
    
  








Related examples in the same category

1.Change value in an array
2.Sum values in an array
3.Totalling a List
4.A program that assigns a list as part of another list.
5.Determine the mean
6.Discard words until we see the "A" marker
7.Empty list
8.Filling an array with 100 zeroes by using the 'x' operator
9.Filling an array with a sequence of numbers by using the '..' operator
10.Reference Counting and Destruction
11.Mix data type in an array
12.Accessing Elements: Populating an array and printing its values