例子:
#!/bin/perl
#site: WWW.jb200.com
# perl引用实例
#
my $aref =[[1,2,3],[4, 5, 6],[7, 8, 9]];
foreach my $key (@{$aref})
{
my $b=$key->[0];
print $b,"n";
}
1
4
7
my @difs;
my (%records,%record1,%record2);
@difs1= qw /a b c/;
@difs2= qw /d e/;
$record1{"xg3"}=@difs1;
$record1{"xg5"}=[@difs2];
print "test value:",$record1{"xg5"}[1],"n";
print "-----------------------------2n";
while(($key,$value)=each %record1){
print "$key:";
# for(my $i=0;$i<scalar @$value;$i++){
# print @$value," ";
# }
my @aa=@{$value};
print @aa;
print "n";