liukaida 发表于 2018-8-31 08:45:53

学习perl的reverse,sort,scalar

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

[*]# 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 bc/;
[*]print "数组的值为abc,scalar指出数组的个数为:",scalar@array_scalar,"\n";
[*]# perlreverse_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小桥流水人家

页: [1]
查看完整版本: 学习perl的reverse,sort,scalar