$main->Show();
Win32::GUI:ialog();
exit(0);
sub search_Click{
open(ZH,"ZH.txt"
my @zh= <ZH>;
chomp(@zh);
open(EN,"EN.txt"
my @en= <EN>;
chomp(@en);
close ZH;
close EN;
foreach my $i(0..$#zh){
my $j=$i+1;
my %match;
$match{$zh[$i]}=$en[$i];
my $node = $main->searchword->Text();
if ( $en[$i] =~ /$node/i)
文本 EN.txt:
I. Review of Work in the Past Five Years
The past five years since the First Session of the Eleventh National People's Congress were a truly extraordinary period of time in the course of China's development.
We effectively countered the severe impact of the global financial crisis and maintained steady and fast economic development.
China's GDP increased from 26.6 trillion yuan to 51.9 trillion yuan, and now ranks second in the world.
Government revenue went up from 5.1 trillion yuan to 11.7 trillion yuan.
A total of 58.7 million urban jobs were created.
There is the sample code for you that read two files data into one array
$ cat read_2f.pl
use strict;
use warnings;
my $sFzh = "ZH.txt";
my $sFen = "EN.txt";
open(FHzh, "<", $sFzh) or die "can't open $sFzh file\n";
open(FHen, "<", $sFen) or die "can't open $sFen file\n";
my @aData;
while(<FHzh>){
# chomp; # if you don't want the newline "\n"
$_ .= <FHen>;
push @aData, $_;
}
# now, you get the two files data on @aData array
my $sCnt = 0;
foreach(@aData){
$sCnt++;
print "Data $sCnt:\n$_\n";
}
$ perl read_2f.pl
Data 1:
一、过去五年工作回顾
I. Review of Work in the Past Five Years
Data 2:
第十一届全国人民代表大会第一次会议以来的五年,是我国发展进程中极不平凡的五年。
The past five years since the First Session of the Eleventh National People's Congress were a truly extraordinary period of time in the course of China's development.
Data 3:
我们有效应对国际金融危机的严重冲击,保持经济平稳较快发展。
We effectively countered the severe impact of the global financial crisis and maintained steady and fast economic development.
Data 4:
国内生产总值从26.6万亿元增加到51.9万亿元,跃升到世界第二位;
China's GDP increased from 26.6 trillion yuan to 51.9 trillion yuan, and now ranks second in the world.
Data 5:
公共财政收入从5.1万亿元增加到11.7万亿元;
Government revenue went up from 5.1 trillion yuan to 11.7 trillion yuan.
Data 6:
累计新增城镇就业5870万人,
A total of 58.7 million urban jobs were created.
you said: it already had searched function but need show more data ...
作者: perllover007 时间: 2014-05-23 16:38
的确是可以搜索了,但出不来我想要的结果,我也搞不清楚哪个地方出了问题,能帮忙给我审核一下我的代码吗?
sub search_Click{
open(ZH,"ZH.txt";
my @zh= <ZH>;
chomp(@zh);
open(EN,"EN.txt";
my @en= <EN>;
chomp(@en);
close ZH;
close EN;
foreach my $i(0..$#zh){
my $j=$i+1;
my %match;#设置哈希,建立中英文的对应;
$match{$zh[$i]}=$en[$i];
my $node = $main->searchword->Text();#读取搜索词;
if ( $en[$i] =~ /$node/i)如果英文文本某一行匹配到搜索词;