zoukankan      html  css  js  c++  java
  • 第三章

    数组元素是以连续的整数来编号,从0开始,之后的每一个元素依次加1
    
    [root@june3 perl]# cat a2.pl 
    @rocks=qw/a b c d e f g/;
    print "$#rocks is $#rocks
    ";
    print "$rocks[$#rocks]
    ";
    [root@june3 perl]# perl a2.pl 
    $#rocks is 6
    g
    
    $#rocks 最后一个元素的索引值
    
    reverse 操作符:
    [root@june3 perl]# cat a3.pl 
    @fred = 6..10;
    @barney = reverse @fred;
    print "@fred is @fred
    ";
    print "@barney is @barney
    ";
    [root@june3 perl]# perl a3.pl 
    @fred is 6 7 8 9 10
    @barney is 10 9 8 7 6
    
    
    
    [root@june3 perl]# cat a4.pl 
    @lines = <STDIN>;
    chomp @lines;
    print "@lines is @lines
    ";
    
    [root@june3 perl]# perl a4.pl 
    1
    2
    3
    @lines is 1 2 3
    
    
    

  • 相关阅读:
    HDU 3537
    POJ 1175
    POJ 1021 人品题
    POJ 2068
    POJ 2608
    POJ 2960
    poj 1635
    ustc 1117
    ural 1468
    数字游戏
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351856.html
Copyright © 2011-2022 走看看