http://www.perlmonks.org?node_id=1110204


in reply to Re: Text::Diff::Table output, but want to show all lines
in thread Text::Diff::Table output, but want to show all lines

Thanks for the reply, 2teez! Apologies that I wasn't clear enough. Say I have the one-liner, which is not what I'm really trying to do and only to demonstrate the behaviors,
perl -MText::Diff -e '$size = 10; @a = sort map { int rand(100) } 1..$ +size; @b = sort map { int rand(100) } 1..$size; print diff \@a, \@b, +{ STYLE => "Table" };'
I don't quite understand how it's supposed to work without the comma after the 2nd item to compare. If you try that in the one-liner, you'll get the error Not a HASH reference at /usr/local/share/perl/5.18.2/Text/Diff.pm line 46. Pressing on anyway, if I run the one-liner with small size which yields many differences and few matching chunks, I do see all the lines as I want to.
+--+----+--+----+
* 0|12  * 0|0   *
* 1|2   * 1|42  *
* 2|24  * 2|43  *
* 3|26  *  |    |
* 4|29  *  |    |
* 5|3   *  |    |
* 6|4   *  |    |
* 7|48  *  |    |
| 8|49  | 3|49  |
* 9|63  * 4|5   *
|  |    * 5|59  *
|  |    * 6|6   *
|  |    * 7|77  *
|  |    * 8|9   *
|  |    * 9|95  *
+--+----+--+----+
However, when you start running with $size=1000 or $size=10000, you'll see breaks in the output where there are large chunks of identical entries in the lists and only the differences and surrounding context is shown. For example,
...
|     |    * 8127|81  *
|     |    * 8128|81  *
| 8157|82  | 8129|82  |
| 8158|82  | 8130|82  |
| 8159|82  | 8131|82  |
+-----+----+-----+----+  <--- lots of identical entries hidden in that break
| 8255|82  | 8227|82  |
| 8256|82  | 8228|82  |
| 8257|82  | 8229|82  |
* 8258|82  *     |    |
* 8259|82  *     |    |
...
For the normal use of diff, hiding the large identical chunks and showing only the differences with context is desirable (arguably, it's the whole point!) But for what I'm working on now, I want to show all of the roughly 6000 lines even if large chunks are identical. I'm hoping there's a way of forcing that behavior or of controlling whatever the chunk break setting is. :)