in reply to Dealing with diff command within perl

First of all, you can easily install Algorithm::Diff yourself, see Yes, even you can use CPAN.

Second, if you read diff, you will find that the exit status for identical files is 0 and otherwise nonzero. If you read system, you will find that it returns the exit status of the program. So you might just want to use that.

  • Comment on Re: Dealing with diff command within perl

Replies are listed 'Best First'.
Re^2: Dealing with diff command within perl
by bart (Canon) on Nov 26, 2011 at 20:59 UTC
    I dare to bet that speedwise, diff the command line program will run circles around Algorithm::Diff.

      First of all, thanks Monks for your suggestions. This is what worked for me-

      use File::Compare; open( DIFFFILE, ">> $diffFile" )|| die " cannot open $diffFile +file !!\n"; print DIFFFILE "Modified Files \n"; print DIFFFILE "<br>\n"; print DIFFFILE "=========== \n"; print DIFFFILE "<br>\n"; if (scalar(@modarry) >= 1) { foreach $f (@modarry) { print DIFFFILE "<br>\n"; print DIFFFILE "$f \n"; print DIFFFILE "<br>\n"; } }elsif (scalar(@modarry) < 1) { print DIFFFILE "\t\n None \n"; print DIFFFILE "<br>\n"; } close (DIFFFILE); foreach $f (@modarry) { @the_string=`diff -r $some_dir/$f $other_dir/$f`; open( DIFFFILE, ">> $diffFile" )|| die " cannot open $diffFile + file !!\n"; print DIFFFILE "<br>\n"; print DIFFFILE "File being diff'd: $f \n"; }

      use File::Compare, to get the list of modified files between two dirs, then run the diff command. Not efficient but it did work

        if (compare("$some_dir/$f","$other_dir/$f") != 0) { print "\n pushing $f to modarray\n"; push @modarry, $f;

        sorry I did not post the actual compare that I used