sanku has asked for the wisdom of the Perl Monks concerning the following question:
from that file i have to completely remove the duplicated elements from that list.N01A0000.f BG1_c22 N01A000X.f BG1_c5 N01A000X.r BG1_c5 N01A002B.f BG1_c38 N01A002B.r BG1_c38 N01A0082.r BG1_c12 N01A00AS.f BG1_c52 N01A00B9.f BG1_c45 N01A00B9.r BG1_c45 N01A00DK.f BG1_c5 N01A00F0.f BG1_c22 N01A00F0.r BG1_c22 N01A00F3.f BG1_c14 N01A00FX.f BG1_c7 N01A00FX.r BG1_c7
Thanks in advanceopen(FILE,"/Downloads/samplefile.txt") or die $!; while(<FILE>){ $_=~s/\s+//g; push(@array1,$_); } close(FILE); #@array1= qw(hi bye hi see u later); my %s = (); $s{$_}++ for @array1; for my $value ( keys %s ) { print "\n".$s{$value}."\n"; if ($s{$value} > 1){ $v=$value; } if($value eq $v){ delete $s{$value}; } else{ print "$value"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: doubt in perl
by graff (Chancellor) on Dec 08, 2008 at 04:52 UTC | |
|
Re: doubt in perl
by moritz (Cardinal) on Dec 08, 2008 at 06:38 UTC | |
|
Re: doubt in perl
by gone2015 (Deacon) on Dec 08, 2008 at 09:09 UTC |