Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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.

In reply to program cant find values that start with $ by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (6)
    As of 2020-05-27 07:30 GMT
    Find Nodes?
      Voting Booth?
      If programming languages were movie genres, Perl would be:

      Results (153 votes). Check out past polls.