in reply to Re: Compare two strings of same length, character-by-character
in thread Compare two strings of same length, character-by-character

I should have added that this is comparing by words based on the split rules given for @from and @to. It could be divided in other ways, I presume, such as by character. As it stands now, without word spaces, the script would highlight the entire string as different if even one character differed in it.

Blessings,

~Polyglot~

  • Comment on Re^2: Compare two strings of same length, character-by-character

Replies are listed 'Best First'.
Re^3: Compare two strings of same length, character-by-character
by karlgoethebier (Abbot) on Nov 29, 2023 at 11:35 UTC

    Why don't you actually outsource your callbacks - as described in the Algorithm::Diff manual? The readability of your code would be significantly improved:

    traverse_sequences( \@seq1, \@seq2, { MATCH => $callback_1, DISCARD_A => $callback_2, DISCARD_B => $callback_3, }, undef, # default key-gen $myArgument1, $myArgument2, $myArgument3, ); $callback_1 = sub {…}; $callback_2 = sub {…}; $callback_3 = sub {…};

    Instead of:

    my $str1 = shift @_; my $str2 = shift @_;

    …write: my ($str1,$str2) = @_;

    The HTML thing is completely incomprehensible to me. Leave it out.

    «The Crux of the Biscuit is the Apostrophe»