Perl学习笔记【Learning Perl】【更新中】
发布时间:2020-12-16 00:44:16 所属栏目:大数据 来源:网络整理
导读:1.?一个给定的表达式在不同的上下文中其含义是不同的。 例如,一个数组的“name”, 在列表context 中,它返回列表元素;在标量context 中, 它返回数组元素的个数。 ? @people = qw( fred barney betty ); @sorted = sort @people; ? ? #列表context:barne
1.?一个给定的表达式在不同的上下文中其含义是不同的。 例如,一个数组的“name”,在列表context 中,它返回列表元素;在标量context 中, 它返回数组元素的个数。 ? @people = qw( fred barney betty ); @sorted = sort @people; ? ? #列表context:barney,betty,fred $number = 42 + @people; ? #标量context:42+3,得到45 ? 我曾经犯的一个错: @arr = qw/a b c d e f g/; print @arr."hello"; #返回的是7hello print @arr,"hello"; #返回的是abcdefghello ? 2. 待续 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |