on Tue, 11 Jun 2002 07:36:48 GMT, [EMAIL PROTECTED] (Chang 
Ming Huei) wrote:

> To count  the repeated data, I can use
> cat xxx.dat | uniq -c 
> 
> It can get the result 
> 3 aa
> 2 bb
> 1 cc
> 
> But how to do it use perl ?

    #! perl -w
    use strict;
    my %words;
    $words{$_}++ while (<DATA>);
    print "$words{$_} $_" 
        for ( sort {$words{$b} cmp $words{$a} } keys %words);

    __DATA__
    aa
    aa
    aa
    bb
    bb
    cc

-- 
felix

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to