Constructing and Dereferencing : Array Definition « Array « Perl






Constructing and Dereferencing

   

#!/usr/bin/perl

use warnings;
use strict;
my @array = (1, 2, 3, 4, 5);
my $array_r = \@array;
print "This is our dereferenced array: @{$array_r}\n";
for (@{$array_r}) {
    print "An element: $_\n";
}
print "The highest element is number $#{$array_r}\n";
print "This is what our reference looks like: $array_r\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.Lists Assigned to Arrays
8.An array is a named list.
9.A program that reads data into an array and writes the array.
10.Build a string array across two lines
11.Construct a string array and output its first element
12.Construct an integer array and output its first element
13.Define two dimensional array
14.An empty list is represented as parentheses with nothing in between
15.Using qw to construct a string array