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.

Aug 282010

Array reference in Perl


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


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

 Leave a Reply



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>