Patch(3)
π NAME π
okay bestie, welcome to Patch(3) from the User Contributed Perl Documentation corner of the internet β it's all about Text::Patch.
Text::Patchβ patches text with given patch. periodt π
β¨ SYNOPSIS β¨
use Text::Patch;
$output = patch( $source, $diff, STYLE => "Unified" );
use Text::Diff;
$src = ...
$dst = ...
$diff = diff( \$src, \$dst, { STYLE => 'Unified' } );
$out = patch( $src, $diff, { STYLE => 'Unified' } );
print "Patch successful" if $out eq $dst;
πΈ DESCRIPTION πΈ
Text::Patch literally combines source text with given diff (difference) data. The diff data is produced by the Text::Diff module or by the standard diff utility (man diff, see the -u option). slay π«Ά
π«Ά patch( $source, $diff, options... ) π«Ά
First argument is source (original) text. Second is the diff data. Third argument can be either a hash reference with options, or all the rest arguments will be considered patch options:
$output = patch( $source, $diff, STYLE => "Unified", ... );
$output = patch( $source, $diff, { STYLE => "Unified", ... } );
π Options π
Options are:
STYLEβ the syntax shown isSTYLE => 'Unified';STYLEcan be"Unified","Context"or"OldStyle". π
The 'Unified' diff format looks like this:
@@ -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!
π TODO π
- Interfaces with files, arrays, etc.
ngl bestie, that's the whole todo list β iconic minimalism π¦
π AUTHOR π
Vladi Belperchinov-Shabanski "Cade"
<cade@biscom.net> <cade@datamax.bg> <cade@cpan.org>
β VERSION β
$Id: Patch.pm,v 1.6 2007/04/07 19:57:41 cade Exp $
okay bestie, that's the page β source/version perl v5.42.0, dated 2012-11-05. bye πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Text-Patch 1.8-bp160.1.12 Β· GPL-2.0+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms