• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            糯米

            TI DaVinci, gstreamer, ffmpeg
            隨筆 - 167, 文章 - 0, 評論 - 47, 引用 - 0
            數據加載中……

            perl 常用函數


            摘自 perldoc.perl.org

            map BLOCK LIST
            map EXPR, LIST
            對于 LIST 里的每一個元素按照 BLOCK 或者 EXPR 里的操作進行求值。
            返回求值結果組成的數組。
            如果返回值是 scalar 類型,則返回結果數組的大小。
            例子:
            返回一組數字對應的字符
            @chars = map(chr, @numbers);
            
            返回一組數字的平方
            my @squares = map { $_ > 5 ? ($_ * $_) : () } @numbers;
            
            返回大于5的數字的平方
            my @squares = map { $_ > 5 ? ($_ * $_) : () } @numbers;
            
            由于 map 總是返回一個列表,因此可以賦值給哈希類型的變量:
            %hash = map { get_a_key_for($_) => $_ } @array;
            
            也可以這樣寫:
            %hash = ();
            foreach (@array) {
                $hash{get_a_key_for($_)} = $_;
            }
            

            -X FILEHANDLE
            文件測試函數:
            -r  File is readable by effective uid/gid.
            -w  File is writable by effective uid/gid.
            -x  File is executable by effective uid/gid.
            -o  File is owned by effective uid.
            -R  File is readable by real uid/gid.
            -W  File is writable by real uid/gid.
            -X  File is executable by real uid/gid.
            -O  File is owned by real uid.
            -e  File exists.
            -z  File has zero size (is empty).
            -s  File has nonzero size (returns size in bytes).
            -f  File is a plain file.
            -d  File is a directory.
            -l  File is a symbolic link.
            -p  File is a named pipe (FIFO), or Filehandle is a pipe.
            -S  File is a socket.
            -b  File is a block special file.
            -c  File is a character special file.
            -t  Filehandle is opened to a tty.
            -u  File has setuid bit set.
            -g  File has setgid bit set.
            -k  File has sticky bit set.
            -T  File is an ASCII text file (heuristic guess).
            -B  File is a "binary" file (opposite of -T).
            -M  Script start time minus file modification time, in days.
            -A  Same for access time.
            -C  Same for inode change time (Unix, may differ for other platforms)
            

            delete EXPR
            EXPR 為哈希變量的 slice 或者是單個元素。
            返回值為刪除掉元素的值,可以是列表。
            如果返回值被要求為 scalar 類型,則返回被刪除的最后一個值。
            delete 也可以用于數組類型的變量,不過它的行為可能不是你所預想的那樣。
            例子:
            %hash = (foo => 11, bar => 22, baz => 33);
            $scalar = delete $hash{foo};             # $scalar is 11
            $scalar = delete @hash{qw(foo bar)};     # $scalar is 22
            @array  = delete @hash{qw(foo bar baz)}; # @array  is (undef,undef,33)
            

            each HASH
            each ARRAY
            each EXPR
            返回哈希的每個 (key, value) 所組成的數組。
            例子:
            while (($key, $value) = each %hash) {
                print $key, "\n";
                delete $hash{$key};   # This is safe
            }
            

            eof FILEHANDLE
            eof ()
            eof
            注意 eof() 與 eof 的區別:
            eof():如果到達了 <> 的最后一個文件的末尾,則返回1
            eof:如果到達了當前文件的末尾,則返回1
            # reset line numbering on each input file
            while (<>) {
                next if /^\s*#/;  # skip comments
                print "$.\t$_";
            } continue {
                close ARGV if eof;  # Not eof()!
            }
            # insert dashes just before last line of last file
            while (<>) {
                if (eof()) {  # check for end of last file
                    print "--------------\n";
                }
                print;
                last if eof();          # needed if we're reading from a terminal
            }
            


            posted on 2011-08-26 18:25 糯米 閱讀(619) 評論(0)  編輯 收藏 引用 所屬分類: Perl

            久久婷婷激情综合色综合俺也去| 久久精品无码一区二区三区日韩 | 欧美伊人久久大香线蕉综合69 | 久久亚洲国产精品五月天婷| 色综合久久精品中文字幕首页| 1000部精品久久久久久久久| 伊人久久大香线蕉综合Av| 亚洲国产精品无码久久久秋霞2| 午夜人妻久久久久久久久| 色妞色综合久久夜夜| 久久久久久a亚洲欧洲aⅴ| 97久久精品人人做人人爽| 久久www免费人成精品香蕉| 国内精品久久久久影院亚洲| 成人午夜精品无码区久久| 国产精品久久久久jk制服| 色噜噜狠狠先锋影音久久| 久久久精品国产| 久久超乳爆乳中文字幕| 久久久国产精品网站| 人妻精品久久久久中文字幕| 久久久噜噜噜久久中文字幕色伊伊 | 国产AV影片久久久久久| 日韩亚洲国产综合久久久| 狠狠综合久久综合88亚洲| 99久久综合狠狠综合久久止| 久久久久成人精品无码| 久久亚洲AV成人无码国产| 久久综合九色综合久99| 亚洲αv久久久噜噜噜噜噜| 国产精品VIDEOSSEX久久发布| 精品国产青草久久久久福利| 久久午夜电影网| 中文字幕日本人妻久久久免费| 一级做a爰片久久毛片16| 亚洲AV日韩AV永久无码久久| 久久久久无码专区亚洲av| 国产∨亚洲V天堂无码久久久| 久久男人中文字幕资源站| 99久久国产综合精品麻豆| 99精品国产综合久久久久五月天|