@fruits = ("Orange", "Grapefruit", "Lemon");#initializing associative array
print "Length of fruits array is " . scalar(@fruits);
@alphabets = (A .. F);
print "Original: @alphabets \n";
push (@alphabets, 'G'); # add G to the last index array
print "Pushing G in the array: @alphabets\n";
pop (@alphabets); # removing last element of array
print "Removing last element from array: @alphabets\n";
pop (@alphabets); # removing last element of array
print "Removing last element from array: @alphabets\n\n";
In Perl, we can use the index method to get the first position/occurrence of a substring
in another string. If the substring does not exist, the index returns -1.