in reply to Need to have perl script to compare two txt files and print difference along with under which segment the difference is

Pls help..

Which part are you having problems with, specifically? Show the code you have; an SSCCE would be best. If you have no code, show your algorithm. If you have no algorithm, create one.

  • Comment on Re: Need to have perl script to compare two txt files and print difference along with under which segment the difference is

Replies are listed 'Best First'.
Re^2: Need to have perl script to compare two txt files and print difference along with under which segment the difference is
by User_04271983 (Initiate) on Jan 24, 2019 at 11:21 UTC
    Hi Thanks for reply!!

      Without sight of the files you are comparing it is difficult to provide a solution. You mention segment names so is it safe to assume that each file contains the same segments but the contents of each segment may differ between files. If this is the case a better approach would be to break each file into segments and compare those, e.g. file test1 segment EFGH compared to file test2 segment EFGH rather than comparing the whole files. That way you can keep track of which segments differ.

      I hope my guess is close and this is helpful. Please post small example data files so that we can give better advice.

      Cheers,

      JohnGG

        Thanks for reply.. And you guessed it right. Both files will have same segments but the contents of each segment may differ between files. I am posting sample data for reference tst1
        lodv OIDSCRIPT LCLABCG NMESCRIPT FRSJFGHT IT RCNGHSGD CURINR CRDUSWD OPWO7GNOxuXVog ODXCP ODXHC ODXIT APSN EJHFG sdmd DUUPPY MDPSJN PCINKSJ FXDEMAIJSKL1 FXCYYEJ EMCYOAK DLMDWJF IRRNKAJ
        contents of tst2
        lodv OIDSCRIPT LCLABCG NMESCRIPT FRSJFGHT IT RCNGHSGD CURINR CRDUSWD OPWO7GNOxuXVog ODXCP ODXHC ODXIT APSN sdmd DUUPPY MDPSJN PCINKSJ FXDEMAIJSKL1 FXCYYEJ EMCYOAK DLMDWJF IRRNKAJ IJFH LAKJSK
        In tst1 under segment "lodv" we have an extra record at last line "EJHFG" Same way, in tst2 under segment "sdmd" we have extra records "IJFH", "LAKJSK" So can we have difference records along with segments. Hope this gives bit more clarity on my question. Thanks in advance:)
        Can someone pls help..