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

List and Array in Perl

发布时间:2020-12-16 00:05:08 所属栏目:大数据 来源:网络整理
导读:scalar ----singular list array ------plural 1. A list is an ordered collection of scalars,and the list is the data. Using (1,2,3) 2. An array is a variable that contians a list,and the array is the variable. Using ['1','2'. '3'] Array and

scalar ----singular

list && array ------plural



1. A list is an ordered collection of scalars,and the list is the data. Using (1,2,3)


2. An array is a variable that contians a list,and the array is the variable. Using ['1','2'. '3']


Array and list can have any number of elements. The smallest one has no elements and the largest can fill all of the available memory.?

Perl's philosophy of " no unnecessary limits".

Using $#array_name as an index.

$array[-1] == $array[$#array]


3. fw shortcut


qw( fred barney betty wilma dino ) == ("fred","barney","betty","wilma","dino")


4,List assigment:

($fred,$barney)=("fred","barney")


5,pop and push operations in List:

@array = 5..9;

$fred = pop(@array); #@array=(5.6,7,8)

$fred = pop(@@array); #@array=(5.6,7)


push(@array,10);# @array =(5,6,10)


6. shift and unshift operations:

@array = qw# dino fred barney #;

$m = shift(#@array); # $m gets " dino" ?and @array now has ("fred","barney")

shift @array; #@array now is empty

unshift(@array,5); # @array has one element (5)


7,Interpolating array into list:

@rock = qw{ a b c d }

$mail = "red@rock.cn" #wrong

$mail = "red@rock.cn"; #right

$mail = 'red@rock.cn' #right

(编辑:李大同)

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

    推荐文章
      热点阅读