Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
#!/usr/bin/perl =head1 SYNOPSIS hidiff old_file new_file =head1 DESCRIPTION Highlight the differences between two files using curses. The result of thinking, wouldn't it be nice to do "watch -d" on two files. =head1 NOTES This is not a diff-like utility, it doesn't yet doi Longest Common Sub +string cleverness so an insertion or deletion will throw the rest of the line +. If I can figure out a way (or ways) to represent a diff in curses highlights and colours then I might implement it. Ideas welcome. hidiff currently isn't rigorous about representing all differences, tabs, line-endings and non-ascii may cause problems. =head1 AUTHOR Brad Bowman, hidiff at bereft net =head1 COPYRIGHT Copyright (c) 2007 Brad Bowman. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut use warnings; use strict; use Curses; my ($old_name, $new_name) = @ARGV; open my $old_fh, $old_name or die "Couldn't open $old_name: $!"; open my $new_fh, $new_name or die "Couldn't open $new_name: $!"; initscr; # Draw files while ( !eof($old_fh) || !eof($new_fh) ) { my $old_line = <$old_fh>; my $new_line = <$new_fh>; chomp($old_line); chomp($new_line); my $old_len = length($old_line); my $new_len = length($new_line); #die join ' ', map { ord($_) } split //, $new_line; my $max_len = ($old_len > $new_len) ? $old_len : $new_len; for my $i (0..$max_len-1) { my $oc = substr($old_line, $i, 1); my $nc = substr($new_line, $i, 1); if ($oc eq $nc) { addch($oc); } else { standout; addch( (ord($nc) != 0) ? $nc : ' '); standend; } } addch("\n"); } refresh; END { endwin; }

In reply to hidiff - char highlight diff utility by bsb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (8)
    As of 2015-07-31 23:49 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (282 votes), past polls