Skip Menu |

This queue is for tickets about the Perl-Dist-Strawberry CPAN distribution.

Report information
The Basics
Id: 108186
Status: new
Priority: 0/
Queue: Perl-Dist-Strawberry

People
Owner: Nobody in particular
Requestors: phillip73uk [...] googlemail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: file::compare bug when comparing files in another directory
Date: Fri, 30 Oct 2015 10:36:02 +0000
To: bug-Perl-Dist-Strawberry [...] rt.cpan.org
From: Phillip George <phillip73uk [...] googlemail.com>
Hi , Firstly, Thanks for strawberry perl it's making my life alot easier. Think I may have found a bug within the File::Compare module. Basically I get different results with File::Compare::compare_text when comparing files in same directory as script to when comparison files are in another directory. To test script you will have to create a directory ''anotherDirectory" which is below the working script directory. use File::Compare; use FileHandle; use File::Compare 'cmp'; sub munge($) { my $line = $_[0]; for ($line) { s/^\s+//; # Trim leading whitespace. s/\s+$//; # Trim trailing whitespace. } return uc($line); } sub Convert_Upper{ my $in = $_[0]; for ($in) { s/^\s+//; # Trim leading whitespace. s/\s+$//; # Trim trailing whitespace. } my $out = uc($in); return uc($in); } sub CompareFiles{ my ($First_line,$Second_line) = @_; print "CompareFiles..1st...$First_line\n"; print "CompareFiles...2nd...$Second_line\n"; $First_line = &Convert_Upper($First_line); $Second_line = &Convert_Upper($Second_line); print "CompareFiles..1st..compare lines...$First_line.\n"; print "CompareFiles..2nd..compare lines...$Second_line.\n"; if($First_line eq $Second_line){ return 0; } else { return 1; } } # # create 3 files: file1.txt and file2.txt are identical but ileDiff.txt is different to the others # #below code works..... print "compare files that are in same directory as script \n"; print "\n"; printf "file1 and fileDiff are %s.\n", compare("file1.txt","fileDiff.txt") ? "different" : "identical"; if ( File::Compare::compare_text("file1.txt","file2.txt", sub{ CompareFiles(@_) } )) { print "sub....file1 and file2 are different.\n"; } else{ print "sub...file1 and file2 are identical.\n"; } # # but now place files in another directory...as below....this doesn't work.....I've also tried file handles ? # print ".......\n"; print "compare files that are in another directory as script \n"; print "\n"; printf "file1 and fileDiff are %s.\n", compare(".\anotherDirectory\file1.txt",".\anotherDirectory\fileDiff.txt") ? "different" : "identical"; if ( File::Compare::compare_text(".\anotherDirectory\file1.txt",".\anotherDirectory\file2.txt", sub{ CompareFiles(@_) } )) { print "sub....file1 and file2 are different.\n"; } else{ print "sub...file1 and file2 are identical.\n"; }

Message body is not shown because sender requested not to inline it.