By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,847 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,847 IT Pros & Developers. It's quick & easy.

compare two datr files

P: 5
hi i have two dat files foldername06.dat(created on feb 13) and p_06(created on feb 16)

both the files are output files and are same except the date which occurs on each line of the output


now i have to write a perl code to compare only the two files not considering the date part such that they are equal .


please let me know the code
Feb 19 '08 #1
Share this Question
Share on Google+
3 Replies


P: 14
it will be helpful for us if you can mention the file format.

i am assuming the file format as below

date:file contents
Option-1
in the above case take the lines if the file and use split(/:/,$lineInFile1) to get the contents and use the same to compare both files by what way you require.

Option-2
use split and get the file contents and then generate 2 temp files for both of your files and then use unix commands to check whether both the files are same not [like cmp, diff commands in unix]

-Nagendra


hi i have two dat files foldername06.dat(created on feb 13) and p_06(created on feb 16)

both the files are output files and are same except the date which occurs on each line of the output


now i have to write a perl code to compare only the two files not considering the date part such that they are equal .


please let me know the code
Feb 19 '08 #2

numberwhun
Expert Mod 2.5K+
P: 3,503
hi i have two dat files foldername06.dat(created on feb 13) and p_06(created on feb 16)

both the files are output files and are same except the date which occurs on each line of the output


now i have to write a perl code to compare only the two files not considering the date part such that they are equal .


please let me know the code
This sounds like it could very well be homework for school. Not only is that against the site policy, but we also require that you do as much of the work (coding) as possible, in order to aid in your learning.

That said, show us your code that you have tried and we will lend assistance.

Regards,

Jeff
Feb 19 '08 #3

numberwhun
Expert Mod 2.5K+
P: 3,503
it will be helpful for us if you can mention the file format.

i am assuming the file format as below

date:file contents
Option-1
in the above case take the lines if the file and use split(/:/,$lineInFile1) to get the contents and use the same to compare both files by what way you require.

Option-2
use split and get the file contents and then generate 2 temp files for both of your files and then use unix commands to check whether both the files are same not [like cmp, diff commands in unix]

-Nagendra
Nagendra,

Please do not go assisting OPs with questions related to Homework. It is against the site policy.

Regards,

Moderator
Feb 19 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.