in reply to Re^2: use to files - grep one to eliminate entries from another file.
in thread use to files - grep one to eliminate entries from another file.

Trying to do all of this in Perl - management doesn't want UNIX commands so I can port this to Windows machines. Thanks.

  • Comment on Re^3: use to files - grep one to eliminate entries from another file.

Replies are listed 'Best First'.
Re^4: use to files - grep one to eliminate entries from another file.
by JavaFan (Canon) on Jan 23, 2012 at 21:26 UTC
Re^4: use to files - grep one to eliminate entries from another file.
by newkendall (Initiate) on Jan 23, 2012 at 21:33 UTC

    Thanks - probably won't work for management; I'll just try to figure it out in Perl on my own. Thanks for your efforts

      At least, look at the manual page, and deduce how comm is implemented. It works on sorted files. Big hint! So, using this big blinking hint, how would I implement this?
      1. Sort both files.
      2. Open both files.
      3. If one of the files is empty, the lines in the other file are unique to said file. Then you're done.
      4. Read a line from both files.
      5. If lines are equal, they appear in both files. Goto 4.
      6. If the line from the first file is less then (string wise) the line from the second, it's unique to the first file. If the first file doesn't have more lines, the rest of the lines in the second file are unique to it. Then you're done. Else, read a line from the first file and goto 5.
      7. The line from the second file is unique to it. If you have exhausted the second file, the rest of the first file are lines unique to it, and you're done. Else read the line from the second file and goto 5.
      Translating that to Perl is left as an exercise to the user who gets paid for it.