.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Patch 3" .TH Patch 3 2023-07-25 "perl v5.38.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Text::Patch \- Patches text with given patch .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Text::Patch; \& \& $output = patch( $source, $diff, STYLE => "Unified" ); \& \& use Text::Diff; \& \& $src = ... \& $dst = ... \& \& $diff = diff( \e$src, \e$dst, { STYLE => \*(AqUnified\*(Aq } ); \& \& $out = patch( $src, $diff, { STYLE => \*(AqUnified\*(Aq } ); \& \& print "Patch successful" if $out eq $dst; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Text::Patch combines source text with given diff (difference) data. Diff data is produced by Text::Diff module or by the standard diff utility (man diff, see \-u option). .ie n .IP "patch( $source, $diff, options... )" 4 .el .IP "patch( \f(CW$source\fR, \f(CW$diff\fR, options... )" 4 .IX Item "patch( $source, $diff, options... )" First argument is source (original) text. Second is the diff data. Third argument can be either hash reference with options or all the rest arguments will be considered patch options: .Sp .Vb 1 \& $output = patch( $source, $diff, STYLE => "Unified", ... ); \& \& $output = patch( $source, $diff, { STYLE => "Unified", ... } ); .Ve .Sp Options are: .Sp .Vb 1 \& STYLE => \*(AqUnified\*(Aq .Ve .Sp STYLE can be "Unified", "Context" or "OldStyle". .Sp The 'Unified' diff format looks like this: .Sp .Vb 10 \& @@ \-1,7 +1,6 @@ \& \-The Way that can be told of is not the eternal Way; \& \-The name that can be named is not the eternal name. \& The Nameless is the origin of Heaven and Earth; \& \-The Named is the mother of all things. \& +The named is the mother of all things. \& + \& Therefore let there always be non\-being, \& so we may see their subtlety, \& And let there always be being, \& @@ \-9,3 +8,6 @@ \& The two are the same, \& But after they are produced, \& they have different names. \& +They both may be called deep and profound. \& +Deeper and more profound, \& +The door of all subtleties! .Ve .SH TODO .IX Header "TODO" .Vb 1 \& Interfaces with files, arrays, etc. .Ve .SH AUTHOR .IX Header "AUTHOR" .Vb 1 \& Vladi Belperchinov\-Shabanski "Cade" \& \& \& \& http://cade.datamax.bg .Ve .SH VERSION .IX Header "VERSION" .Vb 1 \& $Id: Patch.pm,v 1.6 2007/04/07 19:57:41 cade Exp $ .Ve