Loading ...
Sorry, an error occurred while loading the content.

comparing 2 files ??

Expand Messages
  • Abhishek Kumar
    Dear Friends, ... file1: a1a1 a1a2 a1a3 a1a4 ... file2: a1a0 a1a1 a1a5 a1a6 ... Now the problem is if both files file1 and file2 have some line in common (like
    Message 1 of 2 , Dec 4, 2002
    • 0 Attachment
      Dear Friends,

      I have a problem when I have 2 files like:
      -------------
      file1:

      a1a1
      a1a2
      a1a3
      a1a4

      ------------
      file2:

      a1a0
      a1a1
      a1a5
      a1a6

      ------------

      Now the problem is if both files file1 and file2 have some line in
      common (like a1a1 in above), I have do some process say print in file3
      if file1 has distinct line then print in file4(just an exaple).

      How to do this?
      Any Idea?

      Regards
      Abhishek
    • Hans Ginzel
      ... You can create a hash for each file open F1, $file1 or die Cannot open file `$file1 : $! ; $f1{$_}++ while ; close F1; and look the code which
      Message 2 of 2 , Dec 4, 2002
      • 0 Attachment
        On Wed, Dec 04, 2002 at 09:26:35AM -0000, Abhishek Kumar wrote:
        > I have a problem when I have 2 files like:
        > Now the problem is if both files file1 and file2 have some line in
        > common (like a1a1 in above), I have do some process say print in file3
        > if file1 has distinct line then print in file4(just an exaple).

        You can create a hash for each file

        open F1, $file1 or die "Cannot open file `$file1': $!";
        $f1{$_}++ while <F1>;
        close F1;

        and look the code which computes intersection in perldoc perlfaq.

        H.
      Your message has been successfully submitted and would be delivered to recipients shortly.