免费注册 查看新帖 |

Chinaunix

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

为什么这两个字符串会不相等? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-03-18 16:46 |只看该作者 |倒序浏览
本帖最后由 yuqinghua1982 于 2012-03-18 16:47 编辑

我的代码如下:
use strict;
use warnings;
open( ResultURL, ">D:/testdata/keywordurlyodao.txt" )  || die("cant oepn this file!";
open( TEST, "D:/testdata/url.txt" ) || die("cant oepn this file!";
while (<TEST> {
        chomp(my $str = $_);
        print $str."\n" ;
             open( KEYWORD, "D:/testdata/bb.txt" ) || die("cant oepn this file!";
        while (<KEYWORD> {
                chomp;
                my @a       = split /\t/;
                my @tmptags = split /q\=/i, $a[3];
                my $urlbid  = $tmptags[1];
                $urlbid =~ s/\&source=(.*)//i;
                print $urlbid."\n" ;
                my $sourceurl = $tmptags[1];
                $sourceurl =~ s/(.*)\&source=//i;
                if ( $str eq $urlbid) {
                        print "I am here!";
                        print ResultURL $a[1], "\t", $sourceurl, "\n";
                }
        }

}
我的文件里 $str和$urlbid取出来是一样的,都是%BD%A8%B2%C4%C9%FA%B2%FA%BB%FA%D0%B5,为什么字符串比较不相等?
注:
一个文件只有一条记录%BD%A8%B2%C4%C9%FA%B2%FA%BB%FA%D0%B5,另一个文件记录为:29092945        建材生产机械        0.93        http://localhost/search.php?q=%BD%A8%B2%C4%C9%FA%B2%FA%BB%FA%D0%B5&source=yodao_cn+051+011_keyword_%BD%A8%B2%C4%C9%FA%B2%FA%BB%FA%D0%B5        526129        0.93        a        93126        Active        Keyword

论坛徽章:
0
2 [报告]
发表于 2012-03-19 11:02 |只看该作者
已搞定,某些不可见字符导致的
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP