加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

为什么这个插入的插值被Perl解释为除法?

发布时间:2020-12-15 23:31:13 所属栏目:大数据 来源:网络整理
导读:天儿真好, 为什么我从下面的脚本片段中得到以下两个错误? Argument “www4.mh.xxxx.co.uk.logstatsto20090610.gz” isn’t numeric in division (/) at line 56 Argument “/logs/xxxx/200906/mcs0.telhc/borg2” isn’t numeric in division (/) at line 5
天儿真好,

为什么我从下面的脚本片段中得到以下两个错误?

Argument “www4.mh.xxxx.co.uk.logstatsto20090610.gz” isn’t numeric in division (/) at line 56

Argument “/logs/xxxx/200906/mcs0.telhc/borg2” isn’t numeric in division (/) at line 56

变量$dir和$log都是字符串,两个字符串的串联以及中间的斜杠也用引号括起来.

foreach my $dir (@log_dirs) {
            foreach my $log (@log_list) {
line 56:        if ( -s "$dir/$log" ) {
                    push(@logs,$dir/$log);
                }
            }
        }

编辑:第56行绝对是if语句.但是,保罗,你是对的,用引号围绕第57行的分区来解决问题.谢谢.

编辑:Perl版本报告第56行是

stats@fs1:/var/tmp/robertw> /usr/local/perl/bin/perl -v      

This is perl,v5.6.1 built for sun4-solaris

Copyright 1987-2001,Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License,which may be found in the Perl 5 source kit.

Complete documentation for Perl,including FAQ lists,should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet,point your browser at http://www.perl.com/,the Perl Home Page.

stats@fs1:/var/tmp/robertw>

编辑:虽然在Perl中使用插值字符串的方法,假设变量本身就是字符串,并且我试图将它们与斜杠字符连接在一起,不是净结果字符串连接吗?

干杯,

解决方法

第56行可能是它之后的行,你试图划分两个字符串.你可能想要的是什么

foreach my $dir (@log_dirs) {
        foreach my $log (@log_list) {
            if ( -s "$dir/$log" ) {
                push(@logs,"$dir/$log");
            }
        }
    }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读