Hi All,

Could you help me resolve following problem.



I have file: 

John Creamer: 123 345 123 678 345

Erick Morillo: 123 432 876 123 432 

Cris Fortier: 678 123 987 123 345

 

I need to remove duplicated numbers from each line. The output file would be:

 

John Creamer: 123 345 678

Erick Morillo: 123 432 876

Cris Fortier: 678 123 987 345

 

foreach (<INFILE>){
 @temp = split/:/;
 print OUTFILE "\n$temp[0]:";  
 @numbers = split(/\s+/, $temp[1]);

   foreach $number (@numbers){
      $freq{$number}++;
      print OUTFILE $number if $freq{$number}==1;
    }

}

 

The problem is that output file looks like this

John Creamer: 123 345 678

Erick Morillo: 432 876 

Cris Fortier: 987



So this script removes duplicatad numbers from all file but I need it per line :(



Thanks in advance

Vladimir

Reply via email to