惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
V
Visual Studio Blog
博客园 - 三生石上(FineUI控件)
Last Week in AI
Last Week in AI
Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
J
Java Code Geeks
A
About on SuperTechFans
F
Fortinet All Blogs
B
Blog
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Engineering at Meta
Engineering at Meta
Y
Y Combinator Blog
有赞技术团队
有赞技术团队
G
Google Developers Blog
Apple Machine Learning Research
Apple Machine Learning Research
V
V2EX
博客园_首页
博客园 - 叶小钗
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
云风的 BLOG
云风的 BLOG

博客园 - 奈何倾城

用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 Popular HashMap and ConcurrentHashMap Interview Questions 用户中心 - 博客园 用户中心 - 博客园 转:JAVA CAS原理深度分析 java中volatile关键字的含义 JVM系列三:JVM参数设置、分析 Quartz创建多个不同名字的scheduler实例 C# .Net动态调用webService 在SQL Server中使用CLR调用.NET方法 java 调用webservice的各种方法总结 SQL Server索引进阶第三篇:聚集索引 SQL Server性能调教系列(6)—Index Structure and Tuning oracle 索引失效的原因 Perl中字符串编码的处理 Perl的命令行参数 聚簇索引(Clustered Index)和非聚簇索引 (Non- Clustered Index)举例说明
Perl中的引用和解引用
奈何倾城 · 2013-01-01 · via 博客园 - 奈何倾城

对$scalar的引用:

my $variable;
my $reference=\$variable;

对$scalar的解引用:


对@array的引用:

my @array;
my $reference=\@array;

对@array的解引用:

$$reference[element];
$reference->[element];
@$reference; #to access the whole array


对%hash的引用

my %hash;
my $reference=\%hash;

对%hash的解引用:

$$reference{'key'};
$reference->{'key'};
%$reference; #to access the whole hash


对函数的解引用:

&$function(arguments);
$function->(arguments);

对函数的引用:

sub function{}
my $function=\&function;

匿名数组:

my $array;
@$array=("a","b");
$$array[3]="c";
$array->[4]="d";
print @$array;


匿名函数:

my $reference=sub {};
&$reference(parameters);

or

sub function{}

${\function(parameters)};


ref函数返回相应的引用类型:

ref(\@array)=ARRAY;
ref(\%hash)=HASH;
ref(\&function)=CODE;
ref(\\@array)=REF;
ref(\*hash)=GLOB;

$array[$i]->[$j];
$arrat[$i][$j]

${a}=$a;
${"a"}=$a; #是一个符号引用

如果不使用符号引用: use strict 'refs';使用:"no strict 'refs'";

$name="bam";

$$name=1; #$bam=1

$name->[0]=4; # @bam,$bam[0]=4

$name->{X}="Y";

@$name=(); # clear @bam

&$name; #call &bam