Perl: references of array/hash/scalar
# create variables$a = "world";
@array = (10,20,30);
%hash = ("james"=>"pei", "lisa"=>"han");
# create references to them
$ra = \$a;
$rarray= \@array;
$rhash = \%hash;
# create references to constant scalars
$ra = \10;
$rs = \"hello world";
# references to scalars
$ra = \$a;
$$ra += 2;
print $$ra;
# references to Hashes
$rhash = \%hash;
print $rhash->{"key1"};
0 Comments:
Post a Comment
<< Home