Tuna has asked for the wisdom of the Perl Monks concerning the following question:
What I have doesn't work the way I want. Running this code in my test environment returns the following
/home/maleah/sa/current/cluster1 file: test1: 12 file: test2: 24 file: config.hosts: 25 /home/maleah/sa/current/cluster2 file: test1: 37 file: test2: 49 file: config.hosts: 50 /home/maleah/sa/current/cluster3 file: test1: 62 file: test2: 74 file: config.hosts: 75 /home/maleah/sa/current/cluster4 file: test1: 87 file: test2: 99 file: config.hosts: 100 /home/maleah/sa/current/cluster5 file: test1: 112 file: test2: 124 file: config.hosts: 125
#!/usr/bin/perl -w use strict; my $prefixDir = "$ENV{HOME}/sa/current"; my @clusterDirs= ("$prefixDir/cluster1", "$prefixDir/cluster2", "$pref +ixDir/cluster3", "$prefixDir/cluster4", "$prefixDir/cluster5"); use vars qw ($configDir $configFile $lineCount $configFile $fileToComp +are @configFileList); foreach $configDir (@clusterDirs) { opendir DIR, "$configDir" or die "Cannot access $configDir: $!\n"; @configFileList = grep /[^.]/, readdir DIR;print "$configDir\n"; foreach $fileToCompare (@configFileList) { open FILE, "$configDir/$fileToCompare" or die "file not available: $ +!\n"; $lineCount++ while <FILE>; print "file: $fileToCompare: $lineCount\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing files with same name in different directories
by tachyon (Chancellor) on Jul 31, 2001 at 23:00 UTC | |
|
Re: Comparing files with same name in different directories
by scain (Curate) on Jul 31, 2001 at 22:54 UTC | |
|
Re: Comparing files with same name in different directories
by Cubes (Pilgrim) on Jul 31, 2001 at 22:56 UTC | |
|
Re: Comparing files with same name in different directories
by Beatnik (Parson) on Aug 01, 2001 at 00:03 UTC | |
|
Re: Comparing files with same name in different directories
by Rudif (Hermit) on Aug 01, 2001 at 21:00 UTC |