in reply to Removing partially duplicated lines from a file

I am a bit flummoxed, having tried and failed with regex!

What did you try?

  • Comment on Re: Removing partially duplicated lines from a file

Replies are listed 'Best First'.
Re^2: Removing partially duplicated lines from a file
by Sandy_Bio_Perl (Beadle) on Jul 26, 2016 at 16:26 UTC

    I am still working on it.... Trying to adapt some code I used earlier. It doesn't vaguely work!

    sub removeDuplicatesFromOutputText { my $origfile = $_[0]; # eg. HLA-A_0_HBe_for_8_sids.txt; my %hTmp; my $outfile; my $tempout; open (IN, $origfile); while (my $line = <IN>) { if ($line =~ /^\s+\d+/){ next if $line =~ m/^\s*$/; } $line=~s/^\s+//; $line=~s/\s+$//; $tempout = qq{$line\n} unless ($hTmp{$line}++); $outfile .= $tempout; } return $outfile; }