Chapter 6
Now newcount.patch contains the following:
Counter.pm.orig Sat Jan 26 17:37:29 2002
+++ Counter.pm Sat Jan 26 17:44:10 2002
@@ 29,7 +29,10 @@
# Preloaded methods go here.
sub count { return scalar @_ }
+sub count {
+ my $pkg = shift;
+ return scalar @_;
+}
1;
__END__
This format is known as a unified diff. In a unified diff, lines that begin with a +
(plus sign) are the lines that have been added, and lines beginning with a (minus
sign) are the lines that have been removed. Lines without a leading character are
context lines that are unchanged between old and new that surround the changes.
6
Including context enables patch to work even if the original files have changed
since the patch was created. The additional context lines also help human readers
understand the patch; with a little practice, you'll be able to read and understand
patches as easily as reading the original source.
Unified diffs also contain a header listing the old and new filenames and their
modification dates. As I'll demonstrate later, this allows changes to multiple files
to be included in one patch.
Applying a Single File Patch
Applying patches is usually an easy process. The patch program accepts the patch
file on standard input (known in Perl as STDIN). By default, it finds target files auto
matically by examining the patch header and modifies them in place.
6. You can also get context in the normal diff format using the c option, but unified patches are
usually easier to read.
146
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved