免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3656 | 回复: 2
打印 上一主题 下一主题

Use of uninitialized value in substitution (s///) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-12-22 13:56 |只看该作者 |倒序浏览
#!/usr/local/bin/perl -w                                                                                                                        
use strict;                                                                        
use encoding "utf8", STDOUT =>"utf8";                                                                        

while(<>)                                                                        
{
    chomp;                                                                        
    next if not ((defined $_));                                                                        
    my @arr = split /\t/, $_;                                                                        
    if (@arr +0 == 1)                                                                        
    {
        print $_,"\n";                                                                        
        next;                                                                        
    }
    if( $arr[0] =~ s/(^[^0-9a-z\p{Han}]+)|([^0-9a-z\p{Han}]+$)//ig)                                                                        
    {

        print STDERR $_,"\n";                                                                        
    }
        print $arr[0],"\t",$arr[1],"\n";                                                                        
}

出现Use of uninitialized value in substitution (s///) at scripts/rm_no_word\_char.pl line 15, <> line 30 错误?

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
2 [报告]
发表于 2014-12-22 14:23 |只看该作者
输入文件第30行为空行.

if (@arr +0 == 1)                                                                        
    {
        print $_,"\n";                                                                        
        next;                                                                        
    }

改为
if (@arr +0 <= 1)                                                                        
    {
        print $_,"\n";                                                                        
        next;                                                                        
    }

论坛徽章:
0
3 [报告]
发表于 2014-12-22 14:32 |只看该作者
嗯嗯
谢谢。
回复 2# ntwarren


   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP