Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Array reference in Perl

Answer:

Array reference is something like a pointer to a array data structure in Perl

Example:

use strict;
use warnings;

my @a = (1, 2, 3);

my $array_ref = \@a;

$a[2] = "foo";

print $array_ref->[2];    # print out "foo" as change in  @a will also be reflected in its reference
  1. Hash reference in Perl
  2. A simple array in Perl
  3. How to find out whether reference is pointing to a scalar, array or hash in Perl?
  4. Pass hash as reference in Perl
  5. How to convert hash to array in Perl?

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>