{
    "content": [
        {
            "type": "text",
            "text": "# Text::Diff (perldoc)\n\n## NAME\n\nText::Diff - Perform diffs on files and record sets\n\n## SYNOPSIS\n\nuse Text::Diff;\n## Mix and match filenames, strings, file handles, producer subs,\n## or arrays of records; returns diff in a string.\n## WARNING: can return B<large> diffs for large files.\nmy $diff = diff \"file1.txt\", \"file2.txt\", { STYLE => \"Context\" };\nmy $diff = diff \\$string1,   \\$string2,   \\%options;\nmy $diff = diff \\*FH1,       \\*FH2;\nmy $diff = diff \\&reader1,   \\&reader2;\nmy $diff = diff \\@records1,  \\@records2;\n## May also mix input types:\nmy $diff = diff \\@records1,  \"fileB.txt\";\n\n## DESCRIPTION\n\n\"diff()\" provides a basic set of services akin to the GNU \"diff\" utility. It is not anywhere\nnear as feature complete as GNU \"diff\", but it is better integrated with Perl and available on\nall platforms. It is often faster than shelling out to a system's \"diff\" executable for small\nfiles, and generally slower on larger files.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS**\n- **Formatting Classes** (5 subsections)\n- **LIMITATIONS**\n- **SEE ALSO**\n- **REPOSITORY**\n- **AUTHOR**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Text::Diff",
        "section": "",
        "mode": "perldoc",
        "summary": "Text::Diff - Perform diffs on files and record sets",
        "synopsis": "use Text::Diff;\n## Mix and match filenames, strings, file handles, producer subs,\n## or arrays of records; returns diff in a string.\n## WARNING: can return B<large> diffs for large files.\nmy $diff = diff \"file1.txt\", \"file2.txt\", { STYLE => \"Context\" };\nmy $diff = diff \\$string1,   \\$string2,   \\%options;\nmy $diff = diff \\*FH1,       \\*FH2;\nmy $diff = diff \\&reader1,   \\&reader2;\nmy $diff = diff \\@records1,  \\@records2;\n## May also mix input types:\nmy $diff = diff \\@records1,  \"fileB.txt\";",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 14,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 20,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 61,
                "subsections": []
            },
            {
                "name": "Formatting Classes",
                "lines": 15,
                "subsections": [
                    {
                        "name": "Text::Diff::Base",
                        "lines": 2
                    },
                    {
                        "name": "Text::Diff::Unified",
                        "lines": 47
                    },
                    {
                        "name": "Text::Diff::Table",
                        "lines": 35
                    },
                    {
                        "name": "Text::Diff::Context",
                        "lines": 34
                    },
                    {
                        "name": "Text::Diff::OldStyle",
                        "lines": 11
                    }
                ]
            },
            {
                "name": "LIMITATIONS",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 15,
                "subsections": []
            },
            {
                "name": "REPOSITORY",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Text::Diff - Perform diffs on files and record sets\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Text::Diff;\n\n## Mix and match filenames, strings, file handles, producer subs,\n## or arrays of records; returns diff in a string.\n## WARNING: can return B<large> diffs for large files.\nmy $diff = diff \"file1.txt\", \"file2.txt\", { STYLE => \"Context\" };\nmy $diff = diff \\$string1,   \\$string2,   \\%options;\nmy $diff = diff \\*FH1,       \\*FH2;\nmy $diff = diff \\&reader1,   \\&reader2;\nmy $diff = diff \\@records1,  \\@records2;\n\n## May also mix input types:\nmy $diff = diff \\@records1,  \"fileB.txt\";\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "\"diff()\" provides a basic set of services akin to the GNU \"diff\" utility. It is not anywhere\nnear as feature complete as GNU \"diff\", but it is better integrated with Perl and available on\nall platforms. It is often faster than shelling out to a system's \"diff\" executable for small\nfiles, and generally slower on larger files.\n\nRelies on Algorithm::Diff for, well, the algorithm. This may not produce the same exact diff as\na system's local \"diff\" executable, but it will be a valid diff and comprehensible by \"patch\".\nWe haven't seen any differences between Algorithm::Diff's logic and GNU \"diff\"'s, but we have\nnot examined them to make sure they are indeed identical.\n\nNote: If you don't want to import the \"diff\" function, do one of the following:\n\nuse Text::Diff ();\n\nrequire Text::Diff;\n\nThat's a pretty rare occurrence, so \"diff()\" is exported by default.\n\nIf you pass a filename, but the file can't be read, then \"diff()\" will \"croak\".\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "\"diff()\" takes two parameters from which to draw input and a set of options to control its\noutput. The options are:\n\nFILENAMEA, MTIMEA, FILENAMEB, MTIMEB\nThe name of the file and the modification time \"files\".\n\nThese are filled in automatically for each file when \"diff()\" is passed a filename, unless a\ndefined value is passed in.\n\nIf a filename is not passed in and FILENAMEA and FILENAMEB are not provided or are\n\"undef\", the header will not be printed.\n\nUnused on \"OldStyle\" diffs.\n\nOFFSETA, OFFSETB\nThe index of the first line / element. These default to 1 for all parameter types except\nARRAY references, for which the default is 0. This is because ARRAY references are presumed\nto be data structures, while the others are line-oriented text.\n\nSTYLE\n\"Unified\", \"Context\", \"OldStyle\", or an object or class reference for a class providing\n\"fileheader()\", \"hunkheader()\", \"hunk()\", \"hunkfooter()\" and \"filefooter()\" methods. The\ntwo footer() methods are provided for overloading only; none of the formats provide them.\n\nDefaults to \"Unified\" (unlike standard \"diff\", but Unified is what's most often used in\nsubmitting patches and is the most human readable of the three.\n\nIf the package indicated by the STYLE has no \"hunk()\" method, \"diff()\" will load it\nautomatically (lazy loading). Since all such packages should inherit from\n\"Text::Diff::Base\", this should be marvy.\n\nStyles may be specified as class names (\"STYLE => 'Foo'\"), in which case they will be\n\"new()\"ed with no parameters, or as objects (\"STYLE => Foo->new\").\n\nCONTEXT\nHow many lines before and after each diff to display. Ignored on old-style diffs. Defaults\nto 3.\n\nOUTPUT\nExamples and their equivalent subroutines:\n\nOUTPUT   => \\*FOOHANDLE,   # like: sub { print FOOHANDLE shift() }\nOUTPUT   => \\$output,      # like: sub { $output .= shift }\nOUTPUT   => \\@output,      # like: sub { push @output, shift }\nOUTPUT   => sub { $output .= shift },\n\nIf no \"OUTPUT\" is supplied, returns the diffs in a string. If \"OUTPUT\" is a \"CODE\" ref, it\nwill be called once with the (optional) file header, and once for each hunk body with the\ntext to emit. If \"OUTPUT\" is an IO::Handle, output will be emitted to that handle.\n\nFILENAMEPREFIXA, FILENAMEPREFIXB\nThe string to print before the filename in the header. Unused on \"OldStyle\" diffs. Defaults\nare \"---\", \"+++\" for Unified and \"*\", \"+++\" for Context.\n\nKEYGEN, KEYGENARGS\nThese are passed to \"traversesequences\" in Algorithm::Diff.\n\nNote: if neither \"FILENAME\" option is defined, the header will not be printed. If at least one\nis present, the other and both \"MTIME\" options must be present or \"Use of undefined variable\"\nwarnings will be generated (except on \"OldStyle\" diffs, which ignores these options).\n",
                "subsections": []
            },
            "Formatting Classes": {
                "content": "These functions implement the output formats. They are grouped in to classes so \"diff()\" can use\nclass names to call the correct set of output routines and so that you may inherit from them\neasily. There are no constructors or instance methods for these classes, though subclasses may\nprovide them if need be.\n\nEach class has \"fileheader()\", \"hunkheader()\", \"hunk()\", and \"footer()\" methods identical to\nthose documented in the \"Text::Diff::Unified\" section. \"header()\" is called before the \"hunk()\"\nis first called, \"footer()\" afterwards. The default footer function is an empty method provided\nfor overloading:\n\nsub footer { return \"End of patch\\n\" }\n\nSome output formats are provided by external modules (which are loaded automatically), such as\nText::Diff::Table. These are are documented here to keep the documentation simple.\n",
                "subsections": [
                    {
                        "name": "Text::Diff::Base",
                        "content": "Returns \"\" for all methods (other than \"new()\").\n"
                    },
                    {
                        "name": "Text::Diff::Unified",
                        "content": "--- A   Mon Nov 12 23:49:30 2001\n+++ B   Mon Nov 12 23:49:30 2001\n@@ -2,13 +2,13 @@\n2\n3\n4\n-5d\n+5a\n6\n7\n8\n9\n+9a\n10\n11\n-11d\n12\n13\n\nText::Diff::Unified::fileheader\n$s = Text::Diff::Unified->fileheader( $options );\n\nReturns a string containing a unified header. The sole parameter is the \"options\" hash\npassed in to \"diff()\", containing at least:\n\nFILENAMEA  => $fn1,\nMTIMEA     => $mtime1,\nFILENAMEB  => $fn2,\nMTIMEB     => $mtime2\n\nMay also contain\n\nFILENAMEPREFIXA    => \"---\",\nFILENAMEPREFIXB    => \"+++\",\n\nto override the default prefixes (default values shown).\n\nText::Diff::Unified::hunkheader\nText::Diff::Unified->hunkheader( \\@ops, $options );\n\nReturns a string containing the heading of one hunk of unified diff.\n\nText::Diff::Unified::hunk\nText::Diff::Unified->hunk( \\@seqa, \\@seqb, \\@ops, $options );\n\nReturns a string containing the output of one hunk of unified diff.\n"
                    },
                    {
                        "name": "Text::Diff::Table",
                        "content": "+--+----------------------------------+--+------------------------------+\n|  |../Test-Differences-0.2/MANIFEST  |  |../Test-Differences/MANIFEST  |\n|  |Thu Dec 13 15:38:49 2001          |  |Sat Dec 15 02:09:44 2001      |\n+--+----------------------------------+--+------------------------------+\n|  |                                  * 1|Changes                       *\n| 1|Differences.pm                    | 2|Differences.pm                |\n| 2|MANIFEST                          | 3|MANIFEST                      |\n|  |                                  * 4|MANIFEST.SKIP                 *\n| 3|Makefile.PL                       | 5|Makefile.PL                   |\n|  |                                  * 6|t/00escape.t                  *\n| 4|t/00flatten.t                     | 7|t/00flatten.t                 |\n| 5|t/01textvsdata.t                | 8|t/01textvsdata.t            |\n| 6|t/10test.t                        | 9|t/10test.t                    |\n+--+----------------------------------+--+------------------------------+\n\nThis format also goes to some pains to highlight \"invisible\" characters on differing elements by\nselectively escaping whitespace:\n\n+--+--------------------------+--------------------------+\n|  |demowsA.txt             |demowsB.txt             |\n|  |Fri Dec 21 08:36:32 2001  |Fri Dec 21 08:36:50 2001  |\n+--+--------------------------+--------------------------+\n| 1|identical                 |identical                 |\n* 2|        spaced in         |        also spaced in    *\n* 3|embedded space            |embedded        tab       *\n| 4|identical                 |identical                 |\n* 5|        spaced in         |\\ttabbed in               *\n* 6|trailing spaces\\s\\s\\n     |trailing tabs\\t\\t\\n       *\n| 7|identical                 |identical                 |\n* 8|lf line\\n                 |crlf line\\r\\n             *\n* 9|embedded ws               |embedded\\tws              *\n+--+--------------------------+--------------------------+\n\nSee Text::Diff::Table for more details, including how the whitespace escaping works.\n"
                    },
                    {
                        "name": "Text::Diff::Context",
                        "content": "* A   Mon Nov 12 23:49:30 2001\n--- B   Mon Nov 12 23:49:30 2001\n*\n* 2,14\n2\n3\n4\n! 5d\n6\n7\n8\n9\n10\n11\n- 11d\n12\n13\n--- 2,14 ----\n2\n3\n4\n! 5a\n6\n7\n8\n9\n+ 9a\n10\n11\n12\n13\n\nNote: \"hunkheader()\" returns only \"*\\n\".\n"
                    },
                    {
                        "name": "Text::Diff::OldStyle",
                        "content": "5c5\n< 5d\n---\n> 5a\n9a10\n> 9a\n12d12\n< 11d\n\nNote: no \"fileheader()\".\n"
                    }
                ]
            },
            "LIMITATIONS": {
                "content": "Must suck both input files entirely in to memory and store them with a normal amount of Perlish\noverhead (one array location) per record. This is implied by the implementation of\nAlgorithm::Diff, which takes two arrays. If Algorithm::Diff ever offers an incremental mode,\nthis can be changed (contact the maintainers of Algorithm::Diff and \"Text::Diff\" if you need\nthis; it shouldn't be too terribly hard to tie arrays in this fashion).\n\nDoes not provide most of the more refined GNU \"diff\" options: recursive directory tree scanning,\nignoring blank lines / whitespace, etc., etc. These can all be added as time permits and need\narises, many are rather easy; patches quite welcome.\n\nUses closures internally, this may lead to leaks on Perl versions 5.6.1 and prior if used many\ntimes over a process' life time.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "Algorithm::Diff - the underlying implementation of the diff algorithm used by \"Text::Diff\".\n\nYAML::Diff - find difference between two YAML documents.\n\nHTML::Differences - find difference between two HTML documents. This uses a more sane approach\nthan HTML::Diff.\n\nXML::Diff - find difference between two XML documents.\n\nArray::Diff - find the differences between two Perl arrays.\n\nHash::Diff - find the differences between two Perl hashes.\n\nData::Diff - find difference between two arbitrary data structures.\n",
                "subsections": []
            },
            "REPOSITORY": {
                "content": "<https://github.com/neilbowers/Text-Diff>\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Adam Kennedy <adamk@cpan.org>\n\nBarrie Slaymaker <barries@slaysys.com>\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Some parts copyright 2009 Adam Kennedy.\n\nCopyright 2001 Barrie Slaymaker. All Rights Reserved.\n\nYou may use this under the terms of either the Artistic License or GNU Public License v 2.0 or\ngreater.\n",
                "subsections": []
            }
        }
    }
}