加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

`$this`,`@ that`和`%those`在Perl中有什么区别?

发布时间:2020-12-15 21:24:23 所属栏目:大数据 来源:网络整理
导读:$ this,@that和%在Perl中有什么区别? 解决方法 Perl sigils的一个有用的助记符是: $ calar @rray %灰分 Matt Trout写了一个伟大的评论关于Perl sigils blog.fogus.me有用的,所以有粘贴下面: Actually,perl sigils don’t denote variable type – the
$ this,@that和%在Perl中有什么区别?

解决方法

Perl sigils的一个有用的助记符是:

> $ calar
> @rray
>%灰分

Matt Trout写了一个伟大的评论关于Perl sigils blog.fogus.me有用的,所以有粘贴下面:

Actually,perl sigils don’t denote variable type – they denote conjugation – $ is ‘the’,@ is
‘these’,% is ‘map of’ or so – variable type is denoted via [] or {}. You can see this with:

my $foo = 'foo';
    my @foo = ('zero','one','two');
    my $second_foo = $foo[1];
    my @first_and_third_foos = @foo[0,2];
    my %foo = (key1 => 'value1',key2 => 'value2',key3 => 'value3');
    my $key2_foo = $foo{key2};
    my ($key1_foo,$key3_foo) = @foo{'key1','key3'};

so looking at the sigil when skimming perl code tells you what you’re going to -get- rather
than what you’re operating on,pretty much.

This is,admittedly,really confusing until you get used to it,but once you -are- used to it
it can be an extremely useful tool for absorbing information while skimming code.

You’re still perfectly entitled to hate it,of course,but it’s an interesting concept and I
figure you might prefer to hate what’s -actually- going on rather than what you thought was
going on

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读