Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: program cant find values that start with $
by tybalt89 (Monsignor) on Jan 30, 2020 at 18:44 UTC | |
by Anonymous Monk on Jan 30, 2020 at 18:55 UTC | |
Re: program cant find values that start with $
by BillKSmith (Monsignor) on Feb 01, 2020 at 14:13 UTC | |
Re: program cant find values that start with $
by Anonymous Monk on Jan 31, 2020 at 14:22 UTC | |
Re: program cant find values that start with $
by sundialsvc4 (Abbot) on Jan 31, 2020 at 02:13 UTC | |
by LanX (Saint) on Jan 31, 2020 at 02:25 UTC | |
by AnomalousMonk (Archbishop) on Jan 31, 2020 at 08:32 UTC | |
by LanX (Saint) on Jan 31, 2020 at 09:02 UTC | |
by jcb (Parson) on Jan 31, 2020 at 05:08 UTC |
Back to
Seekers of Perl Wisdom