zoukankan      html  css  js  c++  java
  • perl学习之:shift/unshift

    perl中shift 和unshift 操作  

    2008-02-02 11:18:04|  分类: Perl语言|举报|字号 订阅

     
     

    ####################################################################

    # unshift 和shift 对一个数组的开头进行操作(数组的左端有最小下标的元素)。

    # unshift 和shift,如果其数组变量为空,则返回undef。

    ####################################################################

    #!/usr/bin/perl -w

    @array = qw#one two three#;

    $m = shift (@array); #$m 得到“one”, @array 现在为(“two”, “three”)

    shift @array;    #@array 现在为(“three”)

    shift @array;    #@array 现在为空

    $n = shift @array;    #$n 得到undef, @arry 仍为空

    unshift(@array,5);    #@array 现在为(5)

    unshift @array,4;     #@array 现在为(4,5)

    @others = 1..3;

    unshift @array, @others; #array 现在为(1,2,3,4,5)

    shift ARRAY

    如果省略了 ARRAY,那么该函数在子过程和格式的词法范围里移动 @_;
    它在文件范围(通常是主程序)里移动 @ARGV。

  • 相关阅读:
    poj 2000
    poj1316
    poj1922
    poj2017
    poj1833 排列
    poj1338
    poj2136
    poj2242
    IE兼容html5标签
    绑定事件后,某些情况下需要解绑该事件
  • 原文地址:https://www.cnblogs.com/chip/p/4289396.html
Copyright © 2011-2022 走看看