Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Perl Module of String::Diff
Perl
tag: 0.05

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/String
t
tools
.gitignore
.shipit
Changes
MANIFEST
MANIFEST.SKIP
Makefile.PL
README
README.mkdn

README.mkdn

NAME

String::Diff - Simple diff to String

SYNOPSIS

use String::Diff; use String::Diff qw( diff_fully diff diff_merge diff_regexp );# export functions

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

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

# merged my $diff = String::Diff::diff_merge('this is Perl', 'this is Ruby'); print "$diff\n";# this is [Perl]{Ruby}

my $diff = String::Diff::diff_merge('this is Perl', 'this is Ruby', remove_open => '', remove_close => '', append_open => '', append_close => '', ); print "$diff\n";# this is PerlRuby

# change to default marks %String::Diff::DEFAULT_MARKS = ( remove_open => '', remove_close => '', append_open => '', append_close => '', separator => '<-OLD|NEW->', # for diff_merge );

# generated for regexp my $diff = String::Diff::diff_regexp('this is Perl', 'this is Ruby'); print "$diff\n";# this\ is\ (?:Perl|Ruby)

# detailed list my $diff = String::Diff::diff_fully('this is Perl', 'this is Ruby'); for my $line (@{ $diff->[0] }) { print "$line->[0]: '$line->[1]'\n"; } # u: 'this is ' # -: 'Perl'

for my $line (@{ $diff->[1] }) { print "$line->[0]: '$line->[1]'\n"; } # u: 'this is ' # +: 'Ruby'

DESCRIPTION

String::Diff is the difference of a consecutive string is made. after general diff is done, the difference in the line is searchable.

the mark of the addition and the deletion can be freely changed. the color is colored to the terminal with ANSI, using the HTML display it.

after the line is divided, diff is taken when 'linebreak' option is specified.

my($old_string, $new_string) = String::Diff::diff_fully('this is Perl', 'this is Ruby', linebreak => 1); my($old_string, $new_string) = String::Diff::diff('this is Perl', 'this is Ruby', linebreak => 1); my $string = String::Diff::diff_merge('this is Perl', 'this is Ruby', linebreak => 1); my $string = String::Diff::diff_regexp('this is Perl', 'this is Ruby', linebreak => 1);

In diff and diff_merge methods the mark of the difference can be changed.

my $diff = String::Diff::diff('this is Perl', 'this is Ruby',{ remove_open => '', remove_close => '', append_open => '', append_close => '', });

METHODS

  • diff_fully

    the list that divides diff according to the mark is returnd.

    my($old_string, $new_string) = String::Diff::diff_fully('this is Perl', 'this is Ruby');

  • diff

    abd the mark of the deletion and the addition is given to the string.

  • diff_merge

    old and new string is merged with diff.

  • diff_regexp

    the regular expression to which old string and new string are matched with regexp is returned.

AUTHOR

Kazuhiro Osawa ko@yappo.ne.jp

SEE ALSO

Algorithm::Diff

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Something went wrong with that request. Please try again.