As pointed out in sk's reply, you should not be nesting your while loops. And you certainly do not need more than two while loops.

You seem to have an idea already that some files contain "configuration" or "instruction" data (list of patter/replace pairs, list of text files to operate on), so read each of those files into a hash or array, as appropriate. Then figure out how to actually do all the work in a single pass over the data files. Maybe something like this:

use strict; use warnings; # ... initialize some path and file names ... # Open file with search items my %terms; open(FILE,"<$ssearch") or die "$ssearch: $!"; while (<FILE>) { # use $_ chomp; my ( $term, $newterm ) = split /-/; $terms{$term} = $newterm; } # Open file with list of files to be searched open(FILE,"<$fsearch") or die "$fsearch: $!"; my @sigfiles = <FILE>; chomp @sigfiles; # loop over the files to be searched for my $file ( @sigfiles ) { open( IFILE, $file ) or die "$file: $!"; open( OFILE, ">$dir/REVISE_$file" or die "$dir/REVISE_$file: $!"; # loop over lines in the file while (<FILE>) { ## at this point, it's hard to tell what you really want to do... ## you can refer to "keys %terms" and "values %terms" and "$terms{$k +ey}" ... } ## do you need to print something to your output that serves as ## some sort of "summary" for each input file? If so, do that here. ## (you probably should simplify/combine your various printf statemen +ts) }
Good luck with that...

In reply to Re: trouble matching by graff
in thread trouble matching by cravena

Title:
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, details, 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, summary, 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.