学习perl的reverse,sort,scalar,记录一下。
-
[root@OTRS perl]# more reverse_sort_scalar.pl
- #!/usr/bin/perl -w
- use strict;
- #reverse
-
my
@array_reverse = 1..3; -
my
@array_ed = reverse(@array_reverse); -
print
"数组的值为1 2 3,reverse反转数组的值为: ","@array_ed\n"; - #sort
-
my
@array_sort = qw/c b a/; -
my
@sorted = sort@array_sort; -
print
"数组的值为c b a,sort排序后为: "@sorted\n#scalar强制指定标量上下文。 -
my
@array_scalar = qw/a b c/; -
print
"数组的值为abc,scalar指出数组的个数为:scalar@array_scalar,0); ">"\n"; -
[root@OTRS
perl]# perl reverse_sort_scalar.pl -
数组的值为1
2 3,reverse反转数组的值为: 3 2 1 -
数组的值为c
b a,sort排序后为: a b c - 数组的值为abc,scalar指出数组的个数为:3
转载自:http://baiqiuyi.com/linux/perl_reverse_sort_scalar.html?replytocom=1985