首先是数组或者是列表的切片
起始位置结束位置。
use strict;
use warnings;
my @a_arr = qw /wy htt wys jrf/;
my @a_arr1 = @a_arr[0..1];
foreach (@a_arr1){
print $_ ."\n";
}
hash切片:
本质就是通过键值取出多个值:
%score = ("qw"=>"1","wy"=>"2", :http"=>3);
my @three_scores = @score{qw/wy wys http/};
print @three_scores;
打印结果为1 2 3.
补充一个split方法:
将输入的字符串通过split切分为数组,然后通过打散赋值,取出两个值
注:split /?,格式
use strict;
while(<>){
chomp;
my @items = split /:/;
my($card_num,$count) = ($items[1],$items[2]);
print "$card_num,$count";
}
stat函数
0 dev 设备号 驱动器号(C:通常是2,D:通常是3,等等)
1 ino 索引节号 总是0
2 mode 文件的方式 无
3 nlink 链接号