x.txt
try **until **you **succeed
####
y.txt
]]» **]X»]» **]Eõ]» ]]»»
##
##
$result: 1.4
$start: 1.6
The word:
]
##
##
]X»]»
##
##
#!/usr/local/bin/perl -w
use Tk;
#use strict;
our($filename, $info); #Variables to be used in the subs &load_file and &save_file.
#$filename stores the file name typed by the user in the entry widget of the main window.
#$info stores the text message displayed at the bottom of the main window.
my $mw = MainWindow->new; # Main window.
# Create necessary widgets.
my $f = $mw->Frame->pack(-side => 'top', -fill => 'x'); #Create frame.
$f->Label(-text => "Filename:")->pack(-side => 'left', -anchor => 'w'); # Label widget.
$f->Entry(-textvariable => \$filename)->pack(-side => 'left', -anchor => 'w', -fill => 'x', -expand => 1); # Entry widget.
#Button widgets.
$f->Button(-text => "Sug", -command =>\&tged)->pack(-side => 'right');
$f->Button(-text => "Save", -command => \&save_file)->pack(-side => 'right', -anchor => 'e');
$f->Button(-text => "Load", -command => \&load_file)->pack(-side => 'right', -anchor => 'e');
$f->Button(-text => "Det",-command => \&chfile )->pack(-side => 'right', -anchor => 'e');
$f->Button(-text => "Show",-command => \&load_file)->pack(-side => 'right', -anchor => 'e');
$f->Button(-text => "Add?",-command => \&addit)->pack(-side => 'right', -anchor => 'e');
$mw->Label(-textvariable => \$info, -relief => 'ridge')->pack(-side => 'bottom', -fill => 'x'); # Label widget.
#Text widget.
my $t = $mw->Scrolled("Text",-font=>"{as-ttdurga} 24 {bold}")->pack(-side => 'bottom', -fill => 'both', -expand => 1);
MainLoop;
sub chfile
{
open LEX, 'soundex.txt' or die $!;
my %lexicon;
while(){
chomp;
my @words =split;
@lexicon{@words} = (1) x @words;
}
close LEX;
open FILE, "+<$filename" or die $!;
my @missing;
my @data;
while(){
push @missing, grep { ! $lexicon{$_} } split;
push @data,split;
}
#print @missing;
#print "\n@data";
seek FILE, 0, 0; # go to start of file
truncate FILE, 0;
foreach $ditem(@data){
$_ = process($_);
print FILE;
print FILE " ";
foreach $mitem(@missing) {
my $currentposition=tell FILE;
seek FILE,0,1 ;
if ($mitem eq $ditem){
syswrite FILE,"**",4 ;
#print"\n$mitem";
$result=$t->search(-forwards,"**",'end');
# print"\nThe start pos of the pattern:";
# print "\n$result";
$start=$result+.2;
#print "\n$start";
@chars=$t->get("$start","$start wordend");
print "\nThe word:";
print"\n@chars";
#$t->tagConfigure("wrong",-foreground=>"red");
#$t->tagAdd("wrong","$start","$start wordend");
}
}
}
close FILE;
sub process {
return($ditem);
}
}
1;