文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>About issue of chomp command

About issue of chomp command

时间:2010-10-22  来源:yu_jiang163

what 's the issue?    chomp function can't assign to others variable.
for example:
# cat /tmp/a
a
d
g
f
# cat /tmp/b.pl  

#!/usr/bin/perl
$file="/tmp/a";
@array=qw(a b c d);
open(FH,"$file") or die "couldn't open $file:$!";
foreach (<FH>) {
        $line=chomp($_);

        print "$line\n";
        foreach (@array) {
                $item=chomp($_);
                if ("$item" eq "$line" ){
                print "$line\n";
                }
        }
}

resulut:
1
1
1
1

what's the root cause?

   

#!/usr/bin/perl
$file="/tmp/a";
@array=qw(a b c d);
open(FH,"$file") or die "couldn't open $file:$!";
foreach (<FH>) {
        chomp;
        $line = $_;
        foreach (@array) {
                chomp;
                $item=$_;
                if ("$item" eq "$line" ){
                print "$line\n";
                }
        }
}


note: The result of chomp can't assign to other variable       $line = chomp($_);    #return value will be 1
相关阅读 更多 +
排行榜 更多 +
地狱摩托游戏最新版下载

地狱摩托游戏最新版下载

赛车竞速 下载
小猫快来钓鱼游戏下载

小猫快来钓鱼游戏下载

休闲益智 下载
殴打氪金大佬昊天手游下载

殴打氪金大佬昊天手游下载

休闲益智 下载