1Patch(3)              User Contributed Perl Documentation             Patch(3)
2
3
4

NAME

6       Text::Patch - Patches text with given patch
7

SYNOPSIS

9           use Text::Patch;
10
11           $output = patch( $source, $diff, STYLE => "Unified" );
12
13           use Text::Diff;
14
15           $src  = ...
16           $dst  = ...
17
18           $diff = diff( \$src, \$dst, { STYLE => 'Unified' } );
19
20           $out  = patch( $src, $diff, { STYLE => 'Unified' } );
21
22           print "Patch successful" if $out eq $dst;
23

DESCRIPTION

25       Text::Patch combines source text with given diff (difference) data.
26       Diff data is produced by Text::Diff module or by the standard diff
27       utility (man diff, see -u option).
28
29       patch( $source, $diff, options... )
30           First argument is source (original) text. Second is the diff data.
31           Third argument can be either hash reference with options or all the
32           rest arguments will be considered patch options:
33
34               $output = patch( $source, $diff, STYLE => "Unified", ... );
35
36               $output = patch( $source, $diff, { STYLE => "Unified", ... } );
37
38           Options are:
39
40             STYLE => 'Unified'
41
42           STYLE can be "Unified", "Context" or "OldStyle".
43
44           The 'Unified' diff format looks like this:
45
46             @@ -1,7 +1,6 @@
47             -The Way that can be told of is not the eternal Way;
48             -The name that can be named is not the eternal name.
49              The Nameless is the origin of Heaven and Earth;
50             -The Named is the mother of all things.
51             +The named is the mother of all things.
52             +
53              Therefore let there always be non-being,
54                so we may see their subtlety,
55              And let there always be being,
56             @@ -9,3 +8,6 @@
57              The two are the same,
58              But after they are produced,
59                they have different names.
60             +They both may be called deep and profound.
61             +Deeper and more profound,
62             +The door of all subtleties!
63

TODO

65         Interfaces with files, arrays, etc.
66

AUTHOR

68         Vladi Belperchinov-Shabanski "Cade"
69
70         <cade@biscom.net> <cade@datamax.bg> <cade@cpan.org>
71
72         http://cade.datamax.bg
73

VERSION

75         $Id: Patch.pm,v 1.6 2007/04/07 19:57:41 cade Exp $
76
77
78
79perl v5.30.1                      2020-01-30                          Patch(3)
Impressum