#hash_re.pl
use strict;
my @arr =(1 ..10);
my %hash = (
namedArrayKey => \@arr,
anonymousKey =>(1..10)
);
#參照hash中具名的陣列@arr , $get_name_ref參照到整個陣列@arr
my $get_name_ref = $hash{namedArrayKey};
print $get_name_ref,"\n";
print @$get_name_ref,"\n";
print "\n------\n";
#參照hash中匿名的陣列(1..10), $get_name_ref參照到陣列( 1 .. 10)首元素 1
my $get_anony_ref = $hash{anonymousKey};
print $get_anony_ref,"\n";
print @$get_name_ref,"\n";
#輸出結果如下:
#ARRAY(0x104a14d0)
#12345678910
#------
#1
#12345678910
沒有留言:
張貼留言