学习perl的reverse,sort,scalar,记录一下。

  1. [root@OTRS perl]# more reverse_sort_scalar.pl
  2. #!/usr/bin/perl -w
  3. use strict;
  4. #reverse
  5. my @array_reverse = 1..3;
  6. my @array_ed = reverse(@array_reverse);
  7. print "数组的值为1 2 3,reverse反转数组的值为: ","@array_ed\n";
  8. #sort
  9. my @array_sort = qw/c b a/;
  10. my @sorted = sort@array_sort;
  11. print "数组的值为c b a,sort排序后为: ","@sorted\n";
  12. #scalar强制指定标量上下文。
  13. my @array_scalar = qw/a b c/;
  14. print "数组的值为abc,scalar指出数组的个数为:",scalar@array_scalar,"\n";
  15. [root@OTRS perl]# perl reverse_sort_scalar.pl
  16. 数组的值为1 2 3,reverse反转数组的值为: 3 2 1
  17. 数组的值为c b a,sort排序后为: a b c
  18. 数组的值为abc,scalar指出数组的个数为:3

转载自:http://baiqiuyi.com/linux/perl_reverse_sort_scalar.html?replytocom=1985小桥流水人家