I am making a program that reports about what scripts have certain values in them so i can read them more easy. This is going quite well except when i look for values that start with a $ sign except for a bear $ sign. There are hundreds of programs that have something like $text or $file in them and my program just can't find them. So when i test the following program for f.e. $mw it won't find it. I have added the entire script.
use Tk;
use strict;
use warnings;
my $mw = MainWindow->new();
my $frame = $mw->Frame->pack;
my $label = $frame->Label(-text=>"searchvalue?")->pack(-side=>'left',-
+anchor=>'n',-padx=>20,-pady,10);
my $entry = $frame->Entry()->pack(-side =>'left',-anchor=>'n',-padx=>2
+0,-pady=>10);
my $but = $frame->Button(-text=>'go and look',-command => \&go )->pack
+(-side =>'left',-anchor=>'n',-padx=>20,-pady=>10);
my $lb = $frame->Scrolled("Listbox", -scrollbars => 'e');
$lb->configure(-width=>50);
$lb->pack(-side=>'left',-anchor=>'n',-padx=>20,-pady=>20);
my $text = $mw->Scrolled("Text", -scrollbars => 'e')->pack(-side=>'bot
+tom',-anchor=>'w',-padx=>20,-pady=>10);
$lb->bind('<Button-1>',\&search);
MainLoop;
sub search{
my $index = $lb->curselection;
my $bestand = $lb->get($index);
$text->delete('0.0','end');
open(my $fh,"<",$bestand)|| die $!;
while(my $lin = <$fh>){
$text->insert('end',$lin);
};
close $fh;
}
sub go{
$lb->delete(0,'end');
my $zoek = $entry->get;
my $dir = "C:/codes";
opendir(my $dh,$dir);
while(my $file = readdir($dh)){
if(-f "$dir/$file"){
open(my $fh,"<",$file) || die $!;
while(my $line = <$fh>){
if($line =~ /$zoek/){
$lb->insert('end',"$dir/$file");
last;
}
}
close $fh;
}
}
close $dh
}
Maybe some knows about this issue.Tx.