in reply to Re: String matching
in thread String matching
Thanks for everyone's advice and help on this. Here was my final code source which works fantastic in DEV so far.
#!/usr/bin/perl use File::Find; use strict; use warnings; my @dbs; my @dirs=qw(/Users/jwarfel/Documents/perl); find(\&parse, @dirs); sub parse { if (/^rmt[0-9]|[0-9][0-9]|db.lrl$/) { my $rmtdb="$_"; push(@dbs , $rmtdb); } } foreach (qw(dblist.comdbg dblist.varldb)) {push(@dbs , $_);} my %lines; for my $file (@dbs) { open my $fh, $file or die "Can't open $file: $!"; while (<$fh>) { chomp; # Special case of rmtdb $_ = lc $_; if ($_ =~ /^(\w+)\s+/) { $_ = $1; } $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"; } exit 0;
|
|---|