in reply to how to compare column 1 to column 2 and vice versa from multiple rows.
Something like this:
my %seen; while (my $line = <>) { chomp $line; print $line if $seen{ join '', sort split /\s+/, $line }++; }
Use a hash to check for duplicates. Compose a key for the hash in such a way that rows having similar columns give same keys.
Update: Missed ++ has been added.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: how to compare column 1 to column 2 and vice versa from multiple rows.
by BhariD (Sexton) on Oct 01, 2009 at 23:47 UTC | |
by ccn (Vicar) on Oct 02, 2009 at 06:13 UTC | |
by BhariD (Sexton) on Oct 02, 2009 at 18:46 UTC | |
by ccn (Vicar) on Oct 02, 2009 at 20:44 UTC |
In Section
Seekers of Perl Wisdom