Lists Assigned to Arrays : Array Definition « Array « Perl






Lists Assigned to Arrays

    


#!/usr/local/bin/perl

@mixedData = (\@mixedData,,8,,3.14,,"Last");
printArray(@mixedData);

@mixedData = (\@mixedData,'',8,'',3.1,'',"Last");
printArray(@mixedData);

@pieces = @mixedData[4..8];
printArray(@pieces);

@all = @mixedData;
printArray(@all);

sub printArray {
   my @localArray = @_;
   $i = 0;
   foreach $value (@localArray){
      print "Cell number $i = $value \n";
      $i++;
   }
   print "The last cell of the array is $#localArray";
   print "\n\n";
}

   
    
    
    
  








Related examples in the same category

1.Define an array variable called @myList.
2.Create lists of number variables
3.Create lists of text variables
4.Arrays in Perl
5.Array literal
6.String array
7.An array is a named list.
8.A program that reads data into an array and writes the array.
9.Build a string array across two lines
10.Construct a string array and output its first element
11.Construct an integer array and output its first element
12.Define two dimensional array
13.An empty list is represented as parentheses with nothing in between
14.Using qw to construct a string array
15.Constructing and Dereferencing