in reply to String matching

Your script can be done much simpler if you generalize it.

use File::Copy; use File::Find; use strict; use warnings; ### Parse numerical characters and trailing white-space from rmtdb.lrl + for matching. copy("rmtdb.lrl" , "rmtdb.tmp") or die "rmtdb.lrl file cannot be copied: $!\n"; system "cat rmtdb.tmp | cut -d ' ' -f1 > rmtdb.tmp1"; my %lines; for my $file (qw(dblist.comdbg dblist.varldb rmtdb.tmp1)) { open my $fh, $file or die "Can't open $file: $!"; while (<$fh>) { chomp; # Special case of rmtdb $_ = lc $_ if $file eq 'rmtdb.tmp1'; $lines{$_}{$file}++; } close $fh; } foreach my $line (keys %lines) { my @files = sort keys %{$lines{$line}}); next if @files < 2; print "$line is duplicated in: " . join(' ', @files) . "\n"; } ### Cleanup unlink "rmtdb.tmp", "rmtdb.tmp1";

Then if you want to process 20 files, you can just add them to the loop

Replies are listed 'Best First'.
Re^2: Sting matching
by jwesley (Initiate) on Apr 22, 2011 at 00:17 UTC

    Thank you for the response. I haven't tried this yet but I will shortley. The problem I'm having is first I have to search and grep for each rmtdb.lrl file because each server is different. This is what I'm working with for that purpose.

    ### Collect and parse rmt(*)db.lrl files. my @dirs=qw(/bb/bin/jwarfel); find(\&parse, @dirs); sub parse { if (/^rmt[1-9]|[1-9][1-9]|db.lrl$/) { copy("$_" , "$_.tmp"); system "cat $_.tmp | cut -d ' ' -f1 > $_.tmp1"; open $_, "< $_.tmp1"; @$_ = <$_>; close $_; unlink "$_.tmp", "$_.tmp1"; foreach (@$_) {s/$_/\L$_/gi;} $rmtdb="$_"; push(@rmtdbs , $rmtdb); } }