File::DirCompare

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sunilmuki
    New Member
    • Mar 2007
    • 4

    File::DirCompare

    hi, plz tel me how two compare a two files in perl, Ignore whitespace only compare the written satements.....
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    What have you tried so far?

    Comment

    • ajay m
      New Member
      • Mar 2007
      • 20

      #3
      Originally posted by KevinADC
      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

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        Post the code you have written.

        Comment

        • ajay m
          New Member
          • Mar 2007
          • 20

          #5
          Code:
          use File::DirCompare;
          
          # Simple diff -r --brief replacement
          use File::Basename;
          $dir1 = shift;
          $dir2 = shift;
          
          # print "Directories to be searched are $dir1 $dir2 \n";
          
          open APPEND_VSS_UNIQUE_FILE, ">>/perl/test/unique_VSS.txt" or die "Cannot Open File: $!";
          open APPEND_PERFORCE_UNIQUE_FILE, ">>/perl/test/unique_Perforce.txt" or die "Cannot Open File: $!";
          open APPEND_COMMON_DIFFERENT_FILE, ">>/perl/test/common_different_VSSAndPerforce.txt" or die"Cannot Open File: $!";
          open APPEND_COMMON_SIMILAR_FILE, ">>/perl/test/common_similar_VSSAndPerforce.txt" or die "Cannot Open File: $!";
          
          File::DirCompare->compare($dir1, $dir2, sub {
          	my ($a, $b, $fg) = @_;
          	if (! $b) {
          		print APPEND_VSS_UNIQUE_FILE $a, "\n";
          		# printf "Files unique Only in $dir1: %s\n", basename($a);
          		print "Files unique Only in $dir1: $a \n";
          
          	} elsif (! $a) {
          		print APPEND_PERFORCE_UNIQUE_FILE $b, "\n";
          		# printf "Files unique Only in $dir2: %s\n", basename($b);
          		print "Files unique Only in $dir2: $b \n";
          
          	} elsif($fg == 1) {
          		print APPEND_COMMON_DIFFERENT_FILE "$a\||$b\n";
          		print "Files $a and $b are common and different\n";
          
          	} elsif($fg == 0) {
          		print APPEND_COMMON_SIMILAR_FILE "$a\||$b\n";
          		print "Files $a and $b are common and similar\n";
          	}
          });
          
          close APPEND_VSS_UNIQUE_FILE;
          close APPEND_PERFORCE_UNIQUE_FILE;
          close APPEND_COMMON_DIFFERENT_FILE;
          close APPEND_COMMON_SIMILAR_FILE;
          Last edited by miller; Mar 15 '07, 09:07 AM. Reason: Code Tag and ReFormatting

          Comment

          • KevinADC
            Recognized Expert Specialist
            • Jan 2007
            • 4092

            #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. :)

            Comment

            • sunilmuki
              New Member
              • Mar 2007
              • 4

              #7
              Originally posted by KevinADC
              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

              Code:
              use File::DirCompare;
              
              # Simple diff -r --brief replacement
              use File::Basename;
              $dir1 = shift;
              $dir2 = shift;
              
              # print "Directories to be searched are $dir1 $dir2 \n";
              
              open APPEND_VSS_UNIQUE_FILE, ">>/perl/test/unique_VSS.txt" or die "Cannot Open File: $!";
              open APPEND_PERFORCE_UNIQUE_FILE, ">>/perl/test/unique_Perforce.txt" or die "Cannot Open File: $!";
              open APPEND_COMMON_DIFFERENT_FILE, ">>/perl/test/common_different_VSSAndPerforce.txt" or die"Cannot Open File: $!";
              open APPEND_COMMON_SIMILAR_FILE, ">>/perl/test/common_similar_VSSAndPerforce.txt" or die "Cannot Open File: $!";
              
              File::DirCompare->compare($dir1, $dir2, sub {
              	my ($a, $b, $fg) = @_;
              	if (! $b) {
              		print APPEND_VSS_UNIQUE_FILE $a, "\n";
              		# printf "Files unique Only in $dir1: %s\n", basename($a);
              		print "Files unique Only in $dir1: $a \n";
              
              	} elsif (! $a) {
              		print APPEND_PERFORCE_UNIQUE_FILE $b, "\n";
              		# printf "Files unique Only in $dir2: %s\n", basename($b);
              		print "Files unique Only in $dir2: $b \n";
              
              	} elsif($fg == 1) {
              		print APPEND_COMMON_DIFFERENT_FILE "$a\||$b\n";
              		print "Files $a and $b are common and different\n";
              
              	} elsif($fg == 0) {
              		print APPEND_COMMON_SIMILAR_FILE "$a\||$b\n";
              		print "Files $a and $b are common and similar\n";
              	}
              });
              
              close APPEND_VSS_UNIQUE_FILE;
              close APPEND_PERFORCE_UNIQUE_FILE;
              close APPEND_COMMON_DIFFERENT_FILE;
              close APPEND_COMMON_SIMILAR_FILE;
              Last edited by miller; Mar 15 '07, 09:08 AM. Reason: Code Tag and ReFormatting

              Comment

              • miller
                Recognized Expert Top Contributor
                • Oct 2006
                • 1086

                #8
                Originally posted by KevinADC
                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

                Comment

                • sunilmuki
                  New Member
                  • Mar 2007
                  • 4

                  #9
                  Originally posted by sunilmuki
                  pls sir, am not jocking... plzzzzz

                  Code:
                  use File::DirCompare;
                  
                  # Simple diff -r --brief replacement
                  use File::Basename;
                  $dir1 = shift;
                  $dir2 = shift;
                  
                  # print "Directories to be searched are $dir1 $dir2 \n";
                  
                  open APPEND_VSS_UNIQUE_FILE, ">>/perl/test/unique_VSS.txt" or die "Cannot Open File: $!";
                  open APPEND_PERFORCE_UNIQUE_FILE, ">>/perl/test/unique_Perforce.txt" or die "Cannot Open File: $!";
                  open APPEND_COMMON_DIFFERENT_FILE, ">>/perl/test/common_different_VSSAndPerforce.txt" or die"Cannot Open File: $!";
                  open APPEND_COMMON_SIMILAR_FILE, ">>/perl/test/common_similar_VSSAndPerforce.txt" or die "Cannot Open File: $!";
                  
                  File::DirCompare->compare($dir1, $dir2, sub {
                  	my ($a, $b, $fg) = @_;
                  	if (! $b) {
                  		print APPEND_VSS_UNIQUE_FILE $a, "\n";
                  		# printf "Files unique Only in $dir1: %s\n", basename($a);
                  		print "Files unique Only in $dir1: $a \n";
                  
                  	} elsif (! $a) {
                  		print APPEND_PERFORCE_UNIQUE_FILE $b, "\n";
                  		# printf "Files unique Only in $dir2: %s\n", basename($b);
                  		print "Files unique Only in $dir2: $b \n";
                  
                  	} elsif($fg == 1) {
                  		print APPEND_COMMON_DIFFERENT_FILE "$a\||$b\n";
                  		print "Files $a and $b are common and different\n";
                  
                  	} elsif($fg == 0) {
                  		print APPEND_COMMON_SIMILAR_FILE "$a\||$b\n";
                  		print "Files $a and $b are common and similar\n";
                  	}
                  });
                  
                  close APPEND_VSS_UNIQUE_FILE;
                  close APPEND_PERFORCE_UNIQUE_FILE;
                  close APPEND_COMMON_DIFFERENT_FILE;
                  close APPEND_COMMON_SIMILAR_FILE;



                  ok sir dont help....

                  Comment

                  • sunilmuki
                    New Member
                    • Mar 2007
                    • 4

                    #10
                    ok sir, dont help

                    Comment

                    • ajay m
                      New Member
                      • Mar 2007
                      • 20

                      #11
                      Perl

                      hi, plz tel me how two compare a two files in perl, Ignore whitespace only compare the written satements.....

                      Comment

                      • arne
                        Recognized Expert Contributor
                        • Oct 2006
                        • 315

                        #12
                        Originally posted by ajay m
                        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?

                        Comment

                        • arne
                          Recognized Expert Contributor
                          • Oct 2006
                          • 315

                          #13
                          Originally posted by ajay m
                          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 )

                          Comment

                          • KevinADC
                            Recognized Expert Specialist
                            • Jan 2007
                            • 4092

                            #14
                            Originally posted by sunilmuki
                            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.

                            Comment

                            Working...