Result#!/usr/bin/perl -w use strict; # array : assume address 123 my @a = qw(one two three); # reference to array in address 123 # (ARRAY(0x123) my $aa = \@a; # referencec to anonymous array containing # one element, the reference to array @a, # (ARRAY(0x123)) # assume $bb = ARRAY(0x789) my $bb = [$aa]; # @{$aa} returns the array at address 123 # - which is just array @a, # the \@{$aa} returns a reference to the # array at address 123. # - so $cc = ARRAY(0x123) my $cc = \@{$aa}; # results print "array a <@a>\n"; print "reference to array a <$aa>\n"; print "reference to anon array containing reference to array <$bb> +\n"; print "contents of array referred to by \$bb <@$bb>\n"; print "reference to the array referred to by \$aa <$cc>\n"; print "contents of array referred to by \$cc, or array a <@$cc>\n" +;
UPDATE Changed the word 'pointer' to 'reference', as per revdiablo's comment.array a <one two three> reference to array a <ARRAY(0x148bac)> reference to anon array containing reference to array <ARRAY(0x138a6c) +> contents of array referred to by $bb <ARRAY(0x148bac)> reference to the array referred to by $aa <ARRAY(0x148bac)> contents of array referred to by $cc, or array a <one two three>
In reply to Re: Array Reference
by Sandy
in thread Array Reference
by rhumbliner
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |