try this:

-----------------------------------------------
@Array = sort <DATA>;
chomp(@Array);
$flag = 0;
for $i (1..$#Array) {
    if (substr($Array[$i], 0, 1) eq substr($Array[$i-1], 0, 1)) {
        print $Array[$i-1], "\n" if $flag == 0;
        print $Array[$i],   "\n";
        $flag = 1;
    } else {
        $flag = 0;
    }
}

__DATA__
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
-----------------------------------------------

Greetings
Friedel Wittrock


-----Urspr�ngliche Nachricht-----
Von: Kenneth Jideofor [ MTN - Ikoyi ] [mailto:[EMAIL PROTECTED]]
Gesendet: Montag, 8. Juli 2002 15:21
An: [EMAIL PROTECTED]
Betreff: Perl Script for Sorting


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     

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

Reply via email to