读书人

perl习题解决思路

发布时间: 2012-03-02 14:40:29 作者: rapoo

perl习题
小骆驼书上的,我想问这程序
#! C:\strawberry\perl\bin
#test.pl
$^I=".bak";
while (<>){
if (/^#!/){
$_.="## Copyright(C) 2010\n";
}
}


.\test.pl a

这里的$^I是什么意思,作用在那个目录

[解决办法]
$^I中的字符串会作为备份文件的扩展名,为空时是undef.

Perl code
#!C:\Perl\bin\perl.exe -w#test.pl$^I=".bak";while (<>){    if (/^#!/)    {        $_.="## Copyright(C) 2010\n";    }    print;#这里加一个输出...} 

读书人网 >perl python

热点推荐