Vladimir Lemberg wrote:
> 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;
>     }
> 
> }
> 

        You are doing dups over the whole file when whatyou are stating is you are 
looking for dups on an individual. The simplest way would be to define the hash 
outside of the loop and undefine it each time before you go through the process of 
printing your numbers.

Wags ;)
> 
> 
> 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



*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to