Szerkesztő:UTF46/src/checker/commondiff.pm

checker/commondiff.pm forráskódja szerkesztés

package checker::commondiff;
use utf8;
use strict;
use warnings;

use Text::WordDiff;

# the next line can be deleted 
use private::ANSIColor; # just using private color scheme for Text::WordDiff::ANSIColor

sub new {bless {},shift};

sub automata {
	my $self=shift;
	return 0;
};

sub check {
	my $self=shift;
	my $title=shift;
	my $old=shift;
	my $new=shift;
	my $summary=shift;
	my $diff=word_diff(\$old,\$new,{STYLE=>'ANSIColor'});
#	$diff.=join(',',map {ord($_)} @{[split(//,$old)]}[0..3,-3,-2,-1])."\n";
#	$diff.=join(',',map {ord($_)} @{[split(//,$new)]}[0..3,-3,-2,-1])."\n";
	$diff.=length($old).'->'.length($new)."\n";
	$diff.="\n".$summary."\n";
	print $diff;
	local $|=1;
	if ($old eq $new) {
		print "$title did not change. Press ENTER to continue without changing anything!";
		my $ok=<STDIN>;
		return 0;
	} else {
		print "$title OK?";
		my $ok=<STDIN>;
		return $ok;
	};
};

1;

en:WTFPL