A modified version of your code
#!/usr/bin/perl
use strict;
use warnings;
my $file = "controls.txt";
# always(!!!) use the three argument form of open
open (FH, "<", $file) or die "Can't open $file for read: $!";
my @lines;
while (<FH>) {
chomp;
push (@lines, $_);
}
close(FH) or die "Cannot close $file: $!";
my %seen = ();
my @uniq = ();
foreach my $line ( @lines ) {
unless ($seen{$line}) {
#if we get here, we have not seen it before
$seen{$line} = 1;
push(@uniq, $line);
}
}
print join(", ",@uniq) , "\n"; # see if it worked
controls.txt contains
1
1
2
3
3
3
3
3
5
5
6
6
7
7
which gives the following output:
1, 2, 3, 5, 6, 7
Hope this helps.
Thomas