in reply to how to remove duplicate based on the first column value

Try the following code. The output is on STDOUT, but you should have no problem modifying ti to output to a file if you need it. The script uses a %seen hash as lookup table to avoid print out duplicates.

#!/usr/bin/perl -Tw use strict; open (my $myfile, "./prova.txt"); my %seen; while (<$myfile>) { chomp; my ($c1, $c2) = split(/\|/); unless (defined $seen{$c1}) { print "$c1$c2\n"; $seen{$c1} = 1; } } close ($myfile);

Hope this helps!

Michele.

Replies are listed 'Best First'.
Re: Re: how to remove duplicate based on the first column value
by tariqahsan (Beadle) on Jun 10, 2003 at 19:53 UTC
    Michele,
    Thanks! your script work.
    - Tariq