请教 wc -l filename 察看文件行数

请教 wc -l filename 察看文件行数

i205300:/web/server_root/dfs/053/localwork/jp/coby/AAS_IOR> wc -l TERSE.IOR512      
8 TERSE.IOR512

这样可以返回的文件行数是正确的。

可是我怎样在perl程序中,将行数 8 返回给一个变量 $count 呢?

谢谢大家执教!
($count, undef) = `wc -l TERSE.IOR512 `
converse,
这句话右边单引号 ,双引号, 不要引号 都试过了,结果都不对。 帮忙我看看,谢谢啦!
($GET_FILE_COUNT[$i], undef) = “wc -l $DAT_DIR[$i]$GET_FILE[$i]$AASget_runno“;

代码1:单引号
for($i=0; $i < 4; $i++) {
            $GET_FILE_COUNT[$i]=0;   给计数器数组初始化为0
        &writelog("INF $0 $GET_FILE_COUNT[$i]");
        ($GET_FILE_COUNT[$i], undef) = 'wc -l $DAT_DIR[$i]$GET_FILE[$i]$AASget_runno';
        &writelog("INF $0 Conut of $DAT_DIR[$i]$GET_FILE[$i]$AASget_runno is $GET_FILE_COUNT[$i]");
}

结果1:
2008-08-03 01:28:10 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl 0
2008-08-03 01:28:10 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl Conut of /web/server_root/dfs/053/localwork/jp/coby/AAS_INS/TERSE.INS514 is 0
2008-08-03 01:28:10 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl 0
2008-08-03 01:28:10 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl Conut of /web/server_root/dfs/053/localwork/jp/coby/AAS_IOR/TERSE.IOR514 is 0
2008-08-03 01:28:10 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl 0
2008-08-03 01:28:10 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl Conut of /web/server_root/dfs/053/localwork/jp/coby/AAS_MES/TERSE.MES514 is 0
2008-08-03 01:28:10 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl 0
2008-08-03 01:28:10 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl Conut of /web/server_root/dfs/053/localwork/jp/coby/AAS_FTR/TERSE.FTR514 is 0


代码2:双引号
for($i=0; $i < 4; $i++) {
            $GET_FILE_COUNT[$i]=0;   给计数器数组初始化为0
        &writelog("INF $0 $GET_FILE_COUNT[$i]");
        ($GET_FILE_COUNT[$i], undef) = "wc -l $DAT_DIR[$i]$GET_FILE[$i]$AASget_runno";
        &writelog("INF $0 Conut of $DAT_DIR[$i]$GET_FILE[$i]$AASget_runno is $GET_FILE_COUNT[$i]");
}

结果2: 同上结果1


代码3:不要引号
for($i=0; $i < 4; $i++) {
            $GET_FILE_COUNT[$i]=0;   给计数器数组初始化为0
        &writelog("INF $0 $GET_FILE_COUNT[$i]");
        ($$GET_FILE_COUNT[$i], undef) = wc -l $DAT_DIR[$i]$GET_FILE[$i]$AASget_runno;
        &writelog("INF $0 Conut of $DAT_DIR[$i]$GET_FILE[$i]$AASget_runno is $GET_FILE_COUNT[$i]");
}

结果3:

2008-08-03 01:36:42 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl 0
2008-08-03 01:36:42 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl Conut of /web/server_root/dfs/053/localwork/jp/coby/AAS_INS/TERSE.INS516 is wc -l $DAT_DIR[$i]$GET_FILE[$i]$AASget_runno

2008-08-03 01:36:42 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl 0
2008-08-03 01:36:42 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl Conut of /web/server_root/dfs/053/localwork/jp/coby/AAS_IOR/TERSE.IOR516 is wc -l $DAT_DIR[$i]$GET_FILE[$i]$AASget_runno
2008-08-03 01:36:42 for TERSE.MES

2008-08-03 01:36:42 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl 0
2008-08-03 01:36:42 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl Conut of /web/server_root/dfs/053/localwork/jp/coby/AAS_MES/TERSE.MES516 is wc -l $DAT_DIR[$i]$GET_FILE[$i]$AASget_runno
2008-08-03 01:36:42 for TERSE.FTR

2008-08-03 01:36:42 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl 0
2008-08-03 01:36:42 INF /web/server_root/bin/053/jp/coby/ebpcoby_AAS_bat_ctl.pl Conut of /web/server_root/dfs/053/localwork/jp/coby/AAS_FTR/TERSE.FTR516 is wc -l $DAT_DIR[$i]$GET_FILE[$i]$AASget_runno
各位高手们,帮帮忙啊!拜托啦!
小弟完全不熟悉此类语言。


QUOTE:
原帖由 ssming0622 于 2008-8-3 00:55 发表
converse,
这句话右边单引号 ,双引号, 不要引号 都试过了,结果都不对。 帮忙我看看,谢谢啦!

可惜那个既不是单引号,也不是双引号,不要引号自然不行。那是反引号(`), 一般在 Esc 下面,和 ~ 在同一个键上。

另外可看下 perldoc perlop 中关于 qx/STRING/ 的介绍。

MMMIX谢谢兄弟啦!