- 论坛徽章:
- 1
|
本帖最后由 yilongyansha 于 2015-07-23 09:56 编辑
- use strict;
- use warnings;
- use utf8;
- open(FILE,"<:encoding(UTF-8)","D:/test1.txt") or die("Can't open test1.txt");
- my (%hash1,%hash2);
- my ($data1,$data2);
- my $count = 0;
- while(my $test = <FILE>){
- #中文
- my $word1 = "中文";
- if($test =~ /(\d)(\d)(\d)(\d)(\d)(\d)$word1/){
- $data1 = ($5)($6)($3)($4)($1)($2); #不知道可不可以这样写
- $hash1{$data1} = $test;
- }
- #英语
- my $word2 = "英语";
- if($test =~ /(\d)(\d)(\d)(\d)(\d)(\d)$word2/){
- $data2 = ($5)($6)($3)($4)($1)($2);
- $hash2{$data2} = $test;
- }
- }
- foreach my $keyword1 (sort keys(%hash1)){
- foreach my $keyword2 (sort keys(%hash2)){
- if($keyword1 eq $keyword2){
- $count++;
- }
- }
- }
- print "count: $count\n";
- close FILE;
复制代码 上面的代码报错:- syntax error at D:/hashtest.pl line 15, near ")("
- syntax error at D:/hashtest.pl line 22, near ")("
- Execution of D:/hashtest.pl aborted due to compilation errors.
复制代码 上面的代码不知道哪里出错了
|
|