Skip to content

Instantly share code, notes, and snippets.

@am0c
Created March 20, 2011 11:17
Show Gist options
  • Select an option

  • Save am0c/878274 to your computer and use it in GitHub Desktop.

Select an option

Save am0c/878274 to your computer and use it in GitHub Desktop.
String::Diff usage script
#!/usr/bin/env perl
use 5.010;
use warnings;
use strict;
use String::Diff;
use Term::ANSIColor;
use Encode;
print "line1: ";
chomp(my $line1 = readline *STDIN);
print "line2: ";
chomp(my $line2 = readline *STDIN);
say "==result==";
$$_ = decode 'UTF-8', $$_ for \$line1, \$line2;
say encode 'UTF-8', $_ for String::Diff::diff(
$line1, $line2,
remove_open => color('bold red'),
append_open => color('bold green'),
remove_close => color('reset'),
append_close => color('reset'),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment