Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Concatenate the diff of files and show in single glance

by scperl (Initiate)
on Feb 11, 2014 at 11:39 UTC ( #1074395=perlquestion: print w/ replies, xml ) Need Help??
scperl has asked for the wisdom of the Perl Monks concerning the following question:

During a process it generates the temporary files with (.new) as suffix to the source files and it show the difference between the source and temp files on screen Source files are file1.h , file2.h and readme.txt

During the process created temporary files are file1.h.new , file2.h.new and readme.txt.new

The differences it shows as below

output1

--- file1.h Tue Feb 11 16:22:12 +++ file1.h.new Tue Feb 11 16:38:37 @@ -35,7 +35,7 @@ #ifndef _ VERSION_H #define _ VERSION_H -#define MAJOR_NUM $VAR{MAJOR} +#define MAJOR_NUM 2 #define MINOR_NUM $VAR{MINOR} #define BUILD_NUM $VAR{BUILD_NUMBER} #define DATE is $VAR{DATE}

output2

--- file2.h Tue Feb 11 16:21:20 +++ file2.h.new Tue Feb 11 16:38:37 @@ -35,7 +35,7 @@ #ifndef _ VERSION_H #define _ VERSION_H -#define MAJOR_NUM $VAR{MAJOR} +#define MAJOR_NUM 2 #define MINOR_NUM $VAR{MINOR} #define BUILD_NUM $VAR{BUILD_NUMBER}

output3:

--- file1.h Tue Feb 11 16:22:12 +++ file1.h.new Tue Feb 11 16:38:37 @@ -37,7 +37,7 @@ #define MAJOR_NUM $VAR{MAJOR} #define MINOR_NUM $VAR{MINOR} -#define BUILD_NUM $VAR{BUILD_NUMBER} +#define BUILD_NUM 897 #define DATE is $VAR{DATE}

output4:

--- file2.h Tue Feb 11 16:21:20 +++ file2.h.new Tue Feb 11 16:38:37 @@ -37,7 +37,7 @@ #define MAJOR_NUM $VAR{MAJOR} #define MINOR_NUM $VAR{MINOR} -#define BUILD_NUM $VAR{BUILD_NUMBER} +#define BUILD_NUM 897 #define 0x00000400

output5 :

--- readme.txt Tue Feb 11 16:21:20 +++ readme.txt.new Tue Feb 11 16:38:37 @@ -1,3 +1,3 @@ -#define MINOR_NUM $VAR{MINOR} +#define MINOR_NUM 0 last line last line

output 6:

--- file1.h Tue Feb 11 16:22:12 +++ file1.h.new Tue Feb 11 16:38:37 @@ -36,7 +36,7 @@ #define _ VERSION_H #define MAJOR_NUM $VAR{MAJOR} -#define MINOR_NUM $VAR{MINOR} +#define MINOR_NUM 0 #define BUILD_NUM $VAR{BUILD_NUMBER} #define DATE is $VAR{DATE}

output 7:

--- file1.h Tue Feb 11 16:22:12 +++ file1.h.new Tue Feb 11 16:38:37 @@ -38,7 +38,7 @@ #define MAJOR_NUM $VAR{MAJOR} #define MINOR_NUM $VAR{MINOR} #define BUILD_NUM $VAR{BUILD_NUMBER} -#define DATE is $VAR{DATE} +#define DATE is 2014-02-11 #define 0x00000400

How can we get the output of difference between files file1.h and file1.h.new to concatenate and show in single glance using perl similarly for other files also (file2.h and readme.txt )

Required OUTPUT for diff of file1.h and file1.h.new is like below

--- file1.h Tue Feb 11 16:22:12 +++ file1.h.new Tue Feb 11 16:38:37 -#define MAJOR_NUM $VAR{MAJOR} +#define MAJOR_NUM 2 -#define MINOR_NUM $VAR{MINOR} +#define MINOR_NUM 0 -#define BUILD_NUM $VAR{BUILD_NUMBER} +#define BUILD_NUM 897 -#define DATE is $VAR{DATE} +#define DATE is 2014-02-11

Required OUTPUT for diff of file2.h and file2.h.new is like below

--- file2.h Tue Feb 11 16:22:12 +++ file2.h.new Tue Feb 11 16:38:37 -#define MAJOR_NUM $VAR{MAJOR} +#define MAJOR_NUM 2 -#define BUILD_NUM $VAR{BUILD_NUMBER} +#define BUILD_NUM 897

Required OUTPUT for diff of readme.txt and readme.txt.new is like below

--- readme.txt Tue Feb 11 16:21:20 +++ readme.txt.new Tue Feb 11 16:38:37 -#define MINOR_NUM $VAR{MINOR} +#define MINOR_NUM 0

Comment on Concatenate the diff of files and show in single glance
Select or Download Code
Re: Concatenate the diff of files and show in single glance
by robby_dobby (Monk) on Feb 11, 2014 at 12:34 UTC

    Greetings scperl,

    So you want a diff of the output files without anything from the intermediate steps? Well, that depends on your process - if it clobbers previously seen differences, you're better off setting your process right than fudging with intermediate diff files. Now, that said, let's move on to the actual task:

    Your question sounds a lot like a task for a diff tool. Did you check if your diff tool (available on *nix machines) doesn't already do the job for you? diff -u or something similar? You can also look at Text::Diff by Ovid.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1074395]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2014-08-30 21:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls