use strict; use warnings; # ... initialize some path and file names ... # Open file with search items my %terms; open(FILE,"<$ssearch") or die "$ssearch: $!"; while () { # 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 = ; 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 () { ## 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{$key}" ... } ## 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 statements) }