Kenneth Jideofor [ MTN - Ikoyi ] wrote:
> Hi all,
> Good day to you.
> 
> Given the table below, I want to extract all entries in Column 1 that
> appeared more than once in the table. These entries should be extracted with
> their respective other entries in the other columns. The result should be
> saved to a file.
> 
> Please, assist me in writing a Perl script that would be able to do this?
> 
> I'll appreciate every assistance towards achieving this.
> 
> Best regards,
> Ken
> 
> 
> Column 1      Column 2        Column 3        Column 4        
> A     234     2AS     ASD     
> B     567     RF5     RFT     
> C     367     789     THB     
> D     231     R5TG    YHJ     
> E             HU8     UJM     
> R     798     23WS    IKL     
> D     099     34RT    UJHG    
> C     678     56U0    WSD     
> J     43      OOPL0   RFGB    
> A     567     23ED    GHN     
> V     32      SDC3    DCXZ    
> B     12      123W    ERDS    
> B     456     SD45    RFG     
> E     780     FGB68   GHN     
> E     654     WERT4   HJM     
> G     234     SCX1    JKL     
> X     567     6YH2    OLP     
> A     34      45RF    TYU     
> B     234     234DCV  RFE     
> E     678     WSA12   SAWE    
> F     908     3ED5    RFDE    
> C     342     RFT67   TGF     
> C     15      7U89    HNG     
> C     897     FDGB    YUJ     
> D     590     6YJI    TRF     
> A     402     9OLIP   6YH     
> B     304     923ED   YHJ     
> B     674     DCF567  UJK     
> A     135     789OIL  LOI     


Assuming @table is tab separated:

use strict;
my %hash;
foreach (@table) {
        my @f = split /\t/, $_;
        if (exists $hash{$f[0]}) {
                print "Dup: $_\n";
                # do what you want with the dups here
                next;
        }
        $hash{$f[0]} = $_;
        print "$_\n";
}

__END__



-- 
   ,-/-  __      _  _         $Bill Luebkert   ICQ=162126130
  (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to