473,385 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

File::DirCompare

hi, plz tel me how two compare a two files in perl, Ignore whitespace only compare the written satements.....
Mar 15 '07 #1
13 3365
KevinADC
4,059 Expert 2GB
What have you tried so far?
Mar 15 '07 #2
ajay m
20
What have you tried so far?
i writtn a code for comparing a two files, it comparing whitespace also, i dont want to whitespace also, only writtn satatements
Mar 15 '07 #3
KevinADC
4,059 Expert 2GB
Post the code you have written.
Mar 15 '07 #4
ajay m
20
Expand|Select|Wrap|Line Numbers
  1. use File::DirCompare;
  2.  
  3. # Simple diff -r --brief replacement
  4. use File::Basename;
  5. $dir1 = shift;
  6. $dir2 = shift;
  7.  
  8. # print "Directories to be searched are $dir1 $dir2 \n";
  9.  
  10. open APPEND_VSS_UNIQUE_FILE, ">>/perl/test/unique_VSS.txt" or die "Cannot Open File: $!";
  11. open APPEND_PERFORCE_UNIQUE_FILE, ">>/perl/test/unique_Perforce.txt" or die "Cannot Open File: $!";
  12. open APPEND_COMMON_DIFFERENT_FILE, ">>/perl/test/common_different_VSSAndPerforce.txt" or die"Cannot Open File: $!";
  13. open APPEND_COMMON_SIMILAR_FILE, ">>/perl/test/common_similar_VSSAndPerforce.txt" or die "Cannot Open File: $!";
  14.  
  15. File::DirCompare->compare($dir1, $dir2, sub {
  16.     my ($a, $b, $fg) = @_;
  17.     if (! $b) {
  18.         print APPEND_VSS_UNIQUE_FILE $a, "\n";
  19.         # printf "Files unique Only in $dir1: %s\n", basename($a);
  20.         print "Files unique Only in $dir1: $a \n";
  21.  
  22.     } elsif (! $a) {
  23.         print APPEND_PERFORCE_UNIQUE_FILE $b, "\n";
  24.         # printf "Files unique Only in $dir2: %s\n", basename($b);
  25.         print "Files unique Only in $dir2: $b \n";
  26.  
  27.     } elsif($fg == 1) {
  28.         print APPEND_COMMON_DIFFERENT_FILE "$a\||$b\n";
  29.         print "Files $a and $b are common and different\n";
  30.  
  31.     } elsif($fg == 0) {
  32.         print APPEND_COMMON_SIMILAR_FILE "$a\||$b\n";
  33.         print "Files $a and $b are common and similar\n";
  34.     }
  35. });
  36.  
  37. close APPEND_VSS_UNIQUE_FILE;
  38. close APPEND_PERFORCE_UNIQUE_FILE;
  39. close APPEND_COMMON_DIFFERENT_FILE;
  40. close APPEND_COMMON_SIMILAR_FILE;
  41.  
Mar 15 '07 #5
KevinADC
4,059 Expert 2GB
hehehe... you and your clone have fun, I see you don't really need any help, your just entertaining yourself. Sort of like forum masturbation I guess. :)
Mar 15 '07 #6
hehehe... you and your clone have fun, I see you don't really need any help, your just entertaining yourself. Sort of like forum masturbation I guess. :)
pls sir, am not jocking... plzzzzz

Expand|Select|Wrap|Line Numbers
  1. use File::DirCompare;
  2.  
  3. # Simple diff -r --brief replacement
  4. use File::Basename;
  5. $dir1 = shift;
  6. $dir2 = shift;
  7.  
  8. # print "Directories to be searched are $dir1 $dir2 \n";
  9.  
  10. open APPEND_VSS_UNIQUE_FILE, ">>/perl/test/unique_VSS.txt" or die "Cannot Open File: $!";
  11. open APPEND_PERFORCE_UNIQUE_FILE, ">>/perl/test/unique_Perforce.txt" or die "Cannot Open File: $!";
  12. open APPEND_COMMON_DIFFERENT_FILE, ">>/perl/test/common_different_VSSAndPerforce.txt" or die"Cannot Open File: $!";
  13. open APPEND_COMMON_SIMILAR_FILE, ">>/perl/test/common_similar_VSSAndPerforce.txt" or die "Cannot Open File: $!";
  14.  
  15. File::DirCompare->compare($dir1, $dir2, sub {
  16.     my ($a, $b, $fg) = @_;
  17.     if (! $b) {
  18.         print APPEND_VSS_UNIQUE_FILE $a, "\n";
  19.         # printf "Files unique Only in $dir1: %s\n", basename($a);
  20.         print "Files unique Only in $dir1: $a \n";
  21.  
  22.     } elsif (! $a) {
  23.         print APPEND_PERFORCE_UNIQUE_FILE $b, "\n";
  24.         # printf "Files unique Only in $dir2: %s\n", basename($b);
  25.         print "Files unique Only in $dir2: $b \n";
  26.  
  27.     } elsif($fg == 1) {
  28.         print APPEND_COMMON_DIFFERENT_FILE "$a\||$b\n";
  29.         print "Files $a and $b are common and different\n";
  30.  
  31.     } elsif($fg == 0) {
  32.         print APPEND_COMMON_SIMILAR_FILE "$a\||$b\n";
  33.         print "Files $a and $b are common and similar\n";
  34.     }
  35. });
  36.  
  37. close APPEND_VSS_UNIQUE_FILE;
  38. close APPEND_PERFORCE_UNIQUE_FILE;
  39. close APPEND_COMMON_DIFFERENT_FILE;
  40. close APPEND_COMMON_SIMILAR_FILE;
  41.  
Mar 15 '07 #7
miller
1,089 Expert 1GB
hehehe... you and your clone have fun, I see you don't really need any help, your just entertaining yourself. Sort of like forum masturbation I guess. :)
Hehe. This joke is actually rather funny. I went ahead and reformatted the code to make it potentially useful for someone else, but I suspect that this is possibly just the module author given that it's only in version .02.

cpan File DirCompare

Anyway, I deleted the other thread as a duplicate post. That makes it a night for me.

Twinkle Twinkle...
- Miller
Mar 15 '07 #8
pls sir, am not jocking... plzzzzz

Expand|Select|Wrap|Line Numbers
  1. use File::DirCompare;
  2.  
  3. # Simple diff -r --brief replacement
  4. use File::Basename;
  5. $dir1 = shift;
  6. $dir2 = shift;
  7.  
  8. # print "Directories to be searched are $dir1 $dir2 \n";
  9.  
  10. open APPEND_VSS_UNIQUE_FILE, ">>/perl/test/unique_VSS.txt" or die "Cannot Open File: $!";
  11. open APPEND_PERFORCE_UNIQUE_FILE, ">>/perl/test/unique_Perforce.txt" or die "Cannot Open File: $!";
  12. open APPEND_COMMON_DIFFERENT_FILE, ">>/perl/test/common_different_VSSAndPerforce.txt" or die"Cannot Open File: $!";
  13. open APPEND_COMMON_SIMILAR_FILE, ">>/perl/test/common_similar_VSSAndPerforce.txt" or die "Cannot Open File: $!";
  14.  
  15. File::DirCompare->compare($dir1, $dir2, sub {
  16.     my ($a, $b, $fg) = @_;
  17.     if (! $b) {
  18.         print APPEND_VSS_UNIQUE_FILE $a, "\n";
  19.         # printf "Files unique Only in $dir1: %s\n", basename($a);
  20.         print "Files unique Only in $dir1: $a \n";
  21.  
  22.     } elsif (! $a) {
  23.         print APPEND_PERFORCE_UNIQUE_FILE $b, "\n";
  24.         # printf "Files unique Only in $dir2: %s\n", basename($b);
  25.         print "Files unique Only in $dir2: $b \n";
  26.  
  27.     } elsif($fg == 1) {
  28.         print APPEND_COMMON_DIFFERENT_FILE "$a\||$b\n";
  29.         print "Files $a and $b are common and different\n";
  30.  
  31.     } elsif($fg == 0) {
  32.         print APPEND_COMMON_SIMILAR_FILE "$a\||$b\n";
  33.         print "Files $a and $b are common and similar\n";
  34.     }
  35. });
  36.  
  37. close APPEND_VSS_UNIQUE_FILE;
  38. close APPEND_PERFORCE_UNIQUE_FILE;
  39. close APPEND_COMMON_DIFFERENT_FILE;
  40. close APPEND_COMMON_SIMILAR_FILE;
  41.  



ok sir dont help....
Mar 15 '07 #9
ok sir, dont help
Mar 15 '07 #10
ajay m
20
hi, plz tel me how two compare a two files in perl, Ignore whitespace only compare the written satements.....
Mar 15 '07 #11
arne
315 Expert 100+
hi, plz tel me how two compare a two files in perl, Ignore whitespace only compare the written satements.....
Does File::Compare do what you need?
Mar 15 '07 #12
arne
315 Expert 100+
hi, plz tel me how two compare a two files in perl, Ignore whitespace only compare the written satements.....
Yet another clone? Or split personality? No ... still the same. (http://www.thescripts.com/forum/thread617209.html )
Mar 15 '07 #13
KevinADC
4,059 Expert 2GB
ok sir, dont help
Do you really need help? Why are you posting with different usernames and answering your own question? If you really need help, fine, if not, stop wasting your time and our time.
Mar 15 '07 #14

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.