亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 11886 | 回復(fù): 6
打印 上一主題 下一主題

ARGV、$ARGV、$ARG、@ARGV四者的關(guān)系及區(qū)別??? [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2008-09-18 16:21 |只看該作者 |倒序?yàn)g覽
請(qǐng)幫忙解釋一下它們之間的關(guān)系及區(qū)別,謝謝!
@ARGV是傳遞的腳本的命令行參數(shù)。

[ 本帖最后由 gaoquanlong 于 2008-9-18 17:21 編輯 ]

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2008-09-18 17:34 |只看該作者

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2008-09-18 17:42 |只看該作者
哦。。。搞不懂。。查查。。

[ 本帖最后由 xiaoshengcaicai 于 2008-9-18 18:36 編輯 ]

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2008-09-18 17:51 |只看該作者
ARGV [ALL] 特殊的文件句柄,它遍歷在 @ARGV 里的所有命令行文件名。通常寫成尖角操作符 里的空文件句柄:<>。

$ARGV [ALL] 當(dāng)使用 <> 或者 readline 操作符從 ARGV 句柄里讀取數(shù)據(jù)的時(shí)候,包含當(dāng)前 文件名。

Perl語言學(xué)習(xí)(第三版中文版):第二十八章:特殊名字,里邊的內(nèi)容。
我就是不理解這些關(guān)系,所以才問的。。。。。。

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2008-09-18 18:33 |只看該作者
好拗口啊。。。

ARGV

    [ALL] The special filehandle that iterates over command-line filenames in @ARGV. Usually written as the null filehandle in the angle operator: <>.
$ARGV

    [ALL] Contains the name of the current file when reading from the ARGV handle using the <> or readline operators.
@ARGV

    [ALL] The array containing the command-line arguments intended for the script. Note that $#ARGV is generally the number of arguments minus one, since $ARGV[0] is the first argument, not the command name; use scalar @ARGV for the number of program arguments. See $0 for the program name.


$ARGV跟ARGV都是跟<>鉆石操作符有關(guān)系的

@ARGV保存了命令行的所有參數(shù)


比如 test.pl  1.txt 2.txt

@ARGV  為(1.txt, 2.txt)

程序里如果寫
while (<>) {
      print "from file $ARGV  get line:" , $_, "\n";
}

將依次讀入1.txt, 2.txt, 并依次讀入每一行。 $ARGV表示當(dāng)前正在讀取的文件名, ARGV表示當(dāng)前正在讀取的文件句柄。

[ 本帖最后由 xiaoshengcaicai 于 2008-9-18 18:46 編輯 ]

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2014-04-23 14:12 |只看該作者
xiaoshengcaicai 發(fā)表于 2008-09-18 18:33
好拗口啊。。。

回答的非常不錯(cuò),解決了我的疑問

論壇徽章:
145
技術(shù)圖書徽章
日期:2013-10-01 15:32:13戌狗
日期:2013-10-25 13:31:35金牛座
日期:2013-11-04 16:22:07子鼠
日期:2013-11-18 18:48:57白羊座
日期:2013-11-29 10:09:11獅子座
日期:2013-12-12 09:57:42白羊座
日期:2013-12-24 16:24:46辰龍
日期:2014-01-08 15:26:12技術(shù)圖書徽章
日期:2014-01-17 13:24:40巳蛇
日期:2014-02-18 14:32:59未羊
日期:2014-02-20 14:12:13白羊座
日期:2014-02-26 12:06:59
7 [報(bào)告]
發(fā)表于 2014-04-23 14:49 |只看該作者
回復(fù) 1# gaoquanlong

Here is the document

$ perldoc perlvar
NAME
    perlvar - Perl predefined variables
    ...

SPECIAL VARIABLES
    The following names have special meaning to Perl. Most punctuation names
    have reasonable mnemonics, or analogs in the shells. Nevertheless, if you
    wish to use long variable names, you need only say:

            use English;
   
    ...
   
  General Variables
    $ARG
    $_      The default input and pattern-searching space. The following pairs
            are equivalent:
            ...

    @ARG
    @_      Within a subroutine the array @_ contains the parameters passed to
            that subroutine. Inside a subroutine, @_ is the default array for
            the array operators "push", "pop", "shift", and "unshift".
            
            See perlsub.
            ...

    It's easy to notice the problem in such a short example, but in more
    complicated code you are looking for trouble if you don't localize changes
    to the special variables.

    $ARGV   Contains the name of the current file when reading from "<>".

    @ARGV   The array @ARGV contains the command-line arguments intended for
            the script. $#ARGV is generally the number of arguments minus one,
            because $ARGV[0] is the first argument, ESC[4mnotESC[0m the program'
s command
            name itself. See $0 for the command name.

    ARGV    The special filehandle that iterates over command-line filenames
            in @ARGV. Usually written as the null filehandle in the angle
            operator "<>". Note that currently "ARGV" only has its magical
            effect within the "<>" operator; elsewhere it is just a plain
            filehandle corresponding to the last file opened by "<>". In
            particular, passing "\*ARGV" as a parameter to a function that
            expects a filehandle may not cause your function to automatically
            read the contents of all the files in @ARGV.


您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP