• <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
            數(shù)據(jù)加載中……

            perl 常用函數(shù)


            摘自 perldoc.perl.org

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

            -X FILEHANDLE
            文件測試函數(shù):
            -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 也可以用于數(shù)組類型的變量,不過它的行為可能不是你所預(yù)想的那樣。
            例子:
            %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) 所組成的數(shù)組。
            例子:
            while (($key, $value) = each %hash) {
                print $key, "\n";
                delete $hash{$key};   # This is safe
            }
            

            eof FILEHANDLE
            eof ()
            eof
            注意 eof() 與 eof 的區(qū)別:
            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 糯米 閱讀(611) 評論(0)  編輯 收藏 引用 所屬分類: Perl

            欧美精品一区二区久久| 人妻精品久久久久中文字幕一冢本| aaa级精品久久久国产片| 99久久婷婷国产综合亚洲| 国产精品一区二区久久精品无码| 久久人搡人人玩人妻精品首页| 亚洲αv久久久噜噜噜噜噜| 99久久超碰中文字幕伊人| 久久久无码精品亚洲日韩软件| 中文精品久久久久人妻不卡| 99久久精品无码一区二区毛片| 中文字幕精品无码久久久久久3D日动漫| 久久丫精品国产亚洲av不卡| 热RE99久久精品国产66热| 人妻精品久久久久中文字幕| 国产精品久久久久久吹潮| 亚洲а∨天堂久久精品| 久久久久久久亚洲Av无码| 久久亚洲国产精品五月天婷| 国产精品久久久久久久久| 久久SE精品一区二区| 久久久久人妻一区精品| 久久久久久综合一区中文字幕 | 97久久综合精品久久久综合| 亚洲精品综合久久| 精品久久久久中文字幕一区| 狼狼综合久久久久综合网| 亚洲人成电影网站久久| 久久久久国产精品麻豆AR影院| 国产精品无码久久综合| 久久久久人妻一区二区三区vr| 久久久亚洲欧洲日产国码是AV| 伊人久久大香线蕉精品不卡| 久久久WWW免费人成精品| 久久久久无码国产精品不卡| 久久人搡人人玩人妻精品首页| 久久久精品久久久久久 | 亚洲色婷婷综合久久| 久久综合五月丁香久久激情| 久久天天日天天操综合伊人av| 精品久久久久中文字|