Append to array : Array Item « Array « Perl






Append to array

    
#!/usr/bin/perl

use strict;
use warnings;

my @array = ('a', 'b', 'c', 'd', 'e', 'f');
print "@array \n";   # produces 'a b c d e f'
$array[6] = "g";
print "@array \n";   # produces 'a b c d e f g'

   
    
    
    
  








Related examples in the same category

1.An array is an ordered list of scalars: strings and/or numbers.
2.Arrays: a collection of similar data elements
3.A program that prints the elements of a list.
4.Print an element in a list of variables
5.Store various type values in an array
6.Append two arrays to form another array
7.Duplicate array elements
8.Mixed Lists
9.Mixed Data Assigned to Array Cells
10.Array Elements
11.Get array last element
12.Creating and initializing an array with list assignment