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

using comm

Expand Messages
  • srinivas reddy
    hi all, how can i get the lines unique in file1 from two files file1 and file2 using comm function -- Best Regards, Srinivas Reddy...... [Non-text portions of
    Message 1 of 4 , Oct 8, 2005
    • 0 Attachment
      hi all,

      how can i get the lines unique in file1 from two files file1 and file2 using
      comm function

      --
      Best Regards,
      Srinivas Reddy......


      [Non-text portions of this message have been removed]
    • Prasanna Goupal
      Hi Srinivas, ################################## my $line= ; my %hash={}; open(FILE, FIRSTFILE.txt ) || die Error in opening first file $! n ; while($line
      Message 2 of 4 , Oct 8, 2005
      • 0 Attachment
        Hi Srinivas,

        ##################################
        my $line='';
        my %hash={};
        open(FILE,"FIRSTFILE.txt") || die "Error in opening first file $!\n";
        while($line =<FILE>)
        {
        $hash{$line}=$line;
        }
        close(FILE);

        open(FILE,"SECONDFILE.txt") || die "Error in opening first file $!\n";
        while($line =<FILE>)
        {
        if(exists($hash{$line})
        {
        print $line;
        }
        }
        close(FILE);


        ##################################

        Thanks.

        Regards,
        Prasanna Goupal

        srinivas reddy <reddysrinivas.k@...> wrote:
        hi all,

        how can i get the lines unique in file1 from two files file1 and file2 using
        comm function

        --
        Best Regards,
        Srinivas Reddy......


        [Non-text portions of this message have been removed]



        Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html



        ---------------------------------
        YAHOO! GROUPS LINKS


        Visit your group "perl-beginner" on the web.

        To unsubscribe from this group, send an email to:
        perl-beginner-unsubscribe@yahoogroups.com

        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


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




        ---------------------------------
        Yahoo! Music Unlimited - Access over 1 million songs. Try it free.

        [Non-text portions of this message have been removed]
      • jabir ahmed
        sorry i dont know the perfect solution through perl but i guess this is a solution that you could try. try using the system commands from command cat file1 tmp
        Message 3 of 4 , Oct 8, 2005
        • 0 Attachment
          sorry i dont know the perfect solution through perl
          but i guess this is a solution that you could try.

          try using the system commands
          from command

          cat file1>tmp
          cat file2>>tmp
          sort tmp|uniq

          this should help.

          in perl
          $file2='xyz';
          $file2='abc';
          $tmp='.tmpfile';
          system('cat $file1>$tmp');
          system(' cat $file2>>$tmp');
          system( 'sort $tmp|uniq' > $newfile);
          open (FH,'$newfile');
          {

          }
          close FH


          On 10/8/05, srinivas reddy <reddysrinivas.k@...> wrote:
          >
          > hi all,
          >
          > how can i get the lines unique in file1 from two files file1 and file2
          > using
          > comm function
          >
          > --
          > Best Regards,
          > Srinivas Reddy......
          >
          >
          > [Non-text portions of this message have been removed]
          >
          >
          >
          > Unsubscribing info is here:
          > http://help.yahoo.com/help/us/groups/groups-32.html
          >
          >
          > ------------------------------
          > YAHOO! GROUPS LINKS
          >
          >
          > - Visit your group "perl-beginner<http://groups.yahoo.com/group/perl-beginner>"
          > on the web.
          > - To unsubscribe from this group, send an email to:
          > perl-beginner-unsubscribe@yahoogroups.com<perl-beginner-unsubscribe@yahoogroups.com?subject=Unsubscribe>
          > - Your use of Yahoo! Groups is subject to the Yahoo! Terms of
          > Service <http://docs.yahoo.com/info/terms/>.
          >
          >
          > ------------------------------
          >



          --
          It matters not whether you win or lose; what matters is whether I win or
          lose.
          Phone: +91 98867 01148
          email: jabirahmed@... , jabirahmed@...
          Instant Messenger:
          yahoo jabirahmed@...,msn : jabir07@...,ICQ: 56327312, Skype:
          jabirahmed


          [Non-text portions of this message have been removed]
        • merlyn@stonehenge.com
          ... Prasanna my %hash={}; Please test your code before posting. This is a *beginner* level mistake (using {} instead of () here), and breaks the code. Since
          Message 4 of 4 , Oct 8, 2005
          • 0 Attachment
            >>>>> "Prasanna" == Prasanna Goupal <perl_developer@...> writes:

            Prasanna> my %hash={};

            Please test your code before posting. This is a *beginner* level
            mistake (using {} instead of () here), and breaks the code.

            Since you've made a beginner-level mistake, your code is not trustworthy
            unless tested first. If you don't have time to test, please don't post.
            It will save us *all* time and grief.

            --
            Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
            <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
            Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
            See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
          Your message has been successfully submitted and would be delivered to recipients shortly.