compare two datr files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chinnu2809
    New Member
    • Feb 2008
    • 5

    #1

    compare two datr files

    hi i have two dat files foldername06.da t(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
  • npidaparthy
    New Member
    • Feb 2008
    • 14

    #2
    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


    Originally posted by chinnu2809
    hi i have two dat files foldername06.da t(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

    Comment

    • numberwhun
      Recognized Expert Moderator Specialist
      • May 2007
      • 3467

      #3
      Originally posted by chinnu2809
      hi i have two dat files foldername06.da t(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

      Comment

      • numberwhun
        Recognized Expert Moderator Specialist
        • May 2007
        • 3467

        #4
        Originally posted by npidaparthy
        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

        Comment

        Working...