String::Diff

Yappo on 2006-11-18T04:39:31

I created String::Diff. String::Diff is line diff tool, very simple.

  # simple diff
  my $diff = String::Diff::diff('this is Perl', 'this is Ruby');
  print "$diff->[0]\n";# this is [Perl]
  print "$diff->[1]\n";# this is {Ruby}


  my $diff = String::Diff::diff('this is Perl', 'this is Ruby',{
      remove_open => '',
      remove_close => '',
      append_open => '',
      append_close => '',
  });
  print "$diff->[0]\n";# this is Perl
  print "$diff->[1]\n";# this is Ruby


Algorithm::Diff is used. thank you.


XML?

jjore on 2006-11-21T18:00:50

So you're tagging the content with XML? You didn't seem to hoist the rest of the document into XML though.

Re: Ooops!

jjore on 2006-11-21T18:05:20

I misunderstood. Whoops. Here's how I'd use this: with Term::ANSIColor.

use Term::ANSIColor 'color';
my $diff = String::Diff::diff('this is Perl', 'this is Ruby',{
      remove_open => color( 'bold red' ),
      remove_close => color( 'reset' ),
      append_open => color( 'bold green' ),
      append_close => color( 'reset' ),
  });